Class: MoySklad::Model::Supply
- Inherits:
-
Client::Base
- Object
- ActiveResource::Base
- Client::Base
- MoySklad::Model::Supply
- Defined in:
- lib/moy_sklad/model/supply.rb
Instance Method Summary collapse
- #add_item(id, options) ⇒ Object
-
#initialize(*args) ⇒ Supply
constructor
A new instance of Supply.
Methods inherited from Client::Base
collection_name, #create, #destroy, element_path, find, new_element_path, #save
Methods inherited from ActiveResource::Base
Constructor Details
#initialize(*args) ⇒ Supply
Returns a new instance of Supply.
3 4 5 6 7 8 |
# File 'lib/moy_sklad/model/supply.rb', line 3 def initialize(*args) super(*args) create_nested_collection(:attribute) create_nested_resource(:sum) create_nested_collection(:shipmentIn) end |
Instance Method Details
#add_item(id, options) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/moy_sklad/model/supply.rb', line 10 def add_item(id, ) item = create_and_load_resource("shipmentIn", { goodUuid: id }.merge!()) if to_a(:shipmentIn).empty? self.shipmentIn = [item] else self.shipmentIn << item end end |