Class: MC2P::CreateObjectItemMixin

Inherits:
ObjectItemMixin show all
Defined in:
lib/mixins.rb

Overview

Allows create an object item

Direct Known Subclasses

SaveObjectItemMixin

Instance Attribute Summary

Attributes inherited from ObjectItemMixin

#_deleted, #json_dict, #resource

Instance Method Summary collapse

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

#_createObject

Creates the object item with the json_dict data



55
56
57
58
59
60
# File 'lib/mixins.rb', line 55

def _create
  obj = @resource.create(
    @json_dict
  )
  @json_dict = obj.json_dict
end

#saveObject

Executes the internal function _create if the object item don’t have id



63
64
65
# File 'lib/mixins.rb', line 63

def save
  _create unless @json_dict.fetch(@id_property, false)
end