Class: MC2P::SaveObjectItemMixin
- Inherits:
-
CreateObjectItemMixin
- Object
- ObjectItemMixin
- CreateObjectItemMixin
- MC2P::SaveObjectItemMixin
- Defined in:
- lib/mixins.rb
Overview
Allows change an object item
Instance Attribute Summary
Attributes inherited from ObjectItemMixin
#_deleted, #json_dict, #resource
Instance Method Summary collapse
-
#_change ⇒ Object
Changes the object item with the json_dict data.
-
#save ⇒ Object
Executes the internal function _create if the object item don’t have id, in other case, call to _change.
Methods inherited from CreateObjectItemMixin
Methods inherited from ObjectItemMixin
#id_required_and_not_deleted, #initialize, #to_s
Constructor Details
This class inherits a constructor from MC2P::ObjectItemMixin
Instance Method Details
#_change ⇒ Object
Changes the object item with the json_dict data
71 72 73 74 75 76 77 78 |
# File 'lib/mixins.rb', line 71 def _change id_required_and_not_deleted obj = @resource.change( @json_dict[@id_property], @json_dict ) @json_dict = obj.json_dict end |
#save ⇒ Object
Executes the internal function _create if the object item don’t have id, in other case, call to _change
82 83 84 85 86 87 88 |
# File 'lib/mixins.rb', line 82 def save if @json_dict.fetch(@id_property, false) _change else _create end end |