Class: MC2P::CRUObjectItem
- Inherits:
-
ReadOnlyObjectItem
- Object
- ObjectItemMixin
- ObjectItem
- ReadOnlyObjectItem
- MC2P::CRUObjectItem
- Defined in:
- lib/base.rb
Overview
Object item that allows retrieve, create and change an item
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ObjectItemMixin
#_deleted, #json_dict, #resource
Instance Method Summary collapse
-
#_change ⇒ Object
Creates the object item with the json_dict data.
-
#_create ⇒ Object
Creates the object item with the json_dict data.
-
#initialize(json_dict, resource) ⇒ CRUObjectItem
constructor
- Initializes an object item Params:
json_dict
- Data of the object
resource
-
Resource used to delete, save, create or retrieve the object.
- Data of the object
- Initializes an object item Params:
-
#save ⇒ Object
Executes the internal function _create if the object item don’t have id.
Methods inherited from ReadOnlyObjectItem
Methods inherited from ObjectItem
#method_missing, #respond_to?, #respond_to_missing?, #set
Methods inherited from ObjectItemMixin
#id_required_and_not_deleted, #to_s
Constructor Details
#initialize(json_dict, resource) ⇒ CRUObjectItem
Initializes an object item Params:
json_dict
-
Data of the object
resource
-
Resource used to delete, save, create or retrieve the object
142 143 144 145 |
# File 'lib/base.rb', line 142 def initialize(json_dict, resource) @save_mixin = SaveObjectItemMixin.new(json_dict, resource) super(json_dict, resource) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MC2P::ObjectItem
Instance Method Details
#_change ⇒ Object
Creates the object item with the json_dict data
156 157 158 159 160 161 |
# File 'lib/base.rb', line 156 def _change @save_mixin.json_dict = @json_dict @save_mixin._deleted = @_deleted @save_mixin._change @json_dict = @save_mixin.json_dict end |
#_create ⇒ Object
Creates the object item with the json_dict data
148 149 150 151 152 153 |
# File 'lib/base.rb', line 148 def _create @save_mixin.json_dict = @json_dict @save_mixin._deleted = @_deleted @save_mixin._create @json_dict = @save_mixin.json_dict end |
#save ⇒ Object
Executes the internal function _create if the object item don’t have id
164 165 166 167 168 169 |
# File 'lib/base.rb', line 164 def save @save_mixin.json_dict = @json_dict @save_mixin._deleted = @_deleted @save_mixin.save @json_dict = @save_mixin.json_dict end |