Class: Scalablepress::Category
- Inherits:
-
Object
- Object
- Scalablepress::Category
- Defined in:
- lib/scalablepress/resources/category.rb
Instance Attribute Summary collapse
-
#category_id ⇒ Object
readonly
Returns the value of attribute category_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ Category
constructor
A new instance of Category.
- #products ⇒ Object
Constructor Details
#initialize(params) ⇒ Category
Returns a new instance of Category.
6 7 8 9 |
# File 'lib/scalablepress/resources/category.rb', line 6 def initialize(params) @name = params["name"] @category_id = params["categoryId"] end |
Instance Attribute Details
#category_id ⇒ Object (readonly)
Returns the value of attribute category_id.
4 5 6 |
# File 'lib/scalablepress/resources/category.rb', line 4 def category_id @category_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/scalablepress/resources/category.rb', line 3 def name @name end |
Class Method Details
.all ⇒ Object
19 20 21 22 |
# 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) ⇒ Object
15 16 17 |
# File 'lib/scalablepress/resources/category.rb', line 15 def self.find_by_id(id) all.select {|c| c.category_id == id }.first end |