Class: MC2P::CRObjectItem

Inherits:
ReadOnlyObjectItem show all
Defined in:
lib/base.rb

Overview

Object item that allows retrieve and create an item

Direct Known Subclasses

PayURLCRObjectItem

Instance Attribute Summary

Attributes inherited from ObjectItemMixin

#_deleted, #json_dict, #resource

Instance Method Summary collapse

Methods inherited from ReadOnlyObjectItem

get, #retrieve

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

#_createObject

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

#saveObject

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