Class: MC2P::CRObjectItem
- Inherits:
-
ReadOnlyObjectItem
- Object
- ObjectItemMixin
- ObjectItem
- ReadOnlyObjectItem
- MC2P::CRObjectItem
- Defined in:
- lib/base.rb
Overview
Object item that allows retrieve and create an item
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ObjectItemMixin
#_deleted, #json_dict, #resource
Instance Method Summary collapse
-
#_create ⇒ Object
Creates the object item with the json_dict data.
-
#initialize(json_dict, resource) ⇒ CRObjectItem
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) ⇒ CRObjectItem
Initializes an object item Params:
json_dict
-
Data of the object
resource
-
Resource used to delete, save, create or retrieve the object
114 115 116 117 |
# File 'lib/base.rb', line 114 def initialize(json_dict, resource) @create_mixin = CreateObjectItemMixin.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
#_create ⇒ Object
Creates the object item with the json_dict data
120 121 122 123 124 125 |
# File 'lib/base.rb', line 120 def _create @create_mixin.json_dict = @json_dict @create_mixin._deleted = @_deleted @create_mixin._create @json_dict = @create_mixin.json_dict end |
#save ⇒ Object
Executes the internal function _create if the object item don’t have id
128 129 130 131 132 133 |
# File 'lib/base.rb', line 128 def save @create_mixin.json_dict = @json_dict @create_mixin._deleted = @_deleted @create_mixin.save @json_dict = @create_mixin.json_dict end |