class MC2P::SaveObjectItemMixin

Allows change an object item

Public Instance Methods

_change() click to toggle source

Changes the object item with the json_dict data

# 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() click to toggle source

Executes the internal function _create if the object item don't have id, in other case, call to _change

# File lib/mixins.rb, line 82
def save
  if @json_dict.fetch(@id_property, false)
    _change
  else
    _create
  end
end