Class: FetchAPI::Item
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
-
.create(options) ⇒ Object
-- Class Methods ############### --.
Instance Method Summary collapse
-
#destroy ⇒ Object
-- Instance Methods ############### --.
-
#initialize(id_or_attributes) ⇒ Item
constructor
A new instance of Item.
- #update(options) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(id_or_attributes) ⇒ Item
Returns a new instance of Item.
5 6 7 8 9 10 11 12 13 |
# File 'lib/fetchapi/item.rb', line 5 def initialize(id_or_attributes) case id_or_attributes when Integer, String @attributes = get("/#{self.class.pluralized_class_name}/#{id_or_attributes.to_s}") @attributes = @attributes[self.class.singularized_class_name] when Hash @attributes = id_or_attributes end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class FetchAPI::Base
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/fetchapi/item.rb', line 3 def attributes @attributes end |
Class Method Details
.create(options) ⇒ Object
--
Class Methods ###############
18 19 20 |
# File 'lib/fetchapi/item.rb', line 18 def self.create() execute(:post, "/items/create", :item => ) end |
Instance Method Details
#destroy ⇒ Object
--
Instance Methods ###############
26 27 28 |
# File 'lib/fetchapi/item.rb', line 26 def destroy delete("/items/#{sku}/delete") end |
#update(options) ⇒ Object
30 31 32 |
# File 'lib/fetchapi/item.rb', line 30 def update() put("/items/#{sku}", :item => ) end |