class Scalablepress::Category

Attributes

category_id[R]
name[R]

Public Class Methods

all() click to toggle source
# File lib/scalablepress/resources/category.rb, line 19
def self.all
  result = API.get("categories")
  result.map { |params| Category.new(params) }
end
find_by_id(id) click to toggle source
# File lib/scalablepress/resources/category.rb, line 15
def self.find_by_id(id)
  all.select {|c| c.category_id == id }.first
end
new(params) click to toggle source
# File lib/scalablepress/resources/category.rb, line 6
def initialize(params)
  @name = params["name"]
  @category_id = params["categoryId"]
end

Public Instance Methods

products() click to toggle source
# File lib/scalablepress/resources/category.rb, line 11
def products
  API.get("categories/#{@category_id}")["products"].map {|x| Product.new(x) }
end