Module: Sequencescape::Api::Resource::Modifications

Included in:
Sequencescape::Api::Resource
Defined in:
lib/sequencescape-api/resource/modifications.rb

Instance Method Summary collapse

Instance Method Details

#initialize(api, json = nil, wrapped = false) ⇒ Object



38
39
40
41
42
# File 'lib/sequencescape-api/resource/modifications.rb', line 38

def initialize(api, json = nil, wrapped = false)
  super
  update_from_json(json, wrapped)
  clear_changes_information
end

#save!(options = nil) ⇒ Object



51
52
53
54
# File 'lib/sequencescape-api/resource/modifications.rb', line 51

def save!(options = nil)
  action = persisted? ? :update : :create
  modify!((options || {}).merge({ action: action }))
end

#update_attributes!(attributes) ⇒ Object Also known as: update!



44
45
46
47
48
# File 'lib/sequencescape-api/resource/modifications.rb', line 44

def update_attributes!(attributes)
  clear_changes_information
  update_from_json(attributes, false)
  modify!(action: :update)
end