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) ⇒ Modifications

Returns a new instance of Modifications

Returns:



35
36
37
38
39
# File 'lib/sequencescape-api/resource/modifications.rb', line 35

def initialize(api, json = nil, wrapped = false)
  super
  update_from_json(json, wrapped)
  changed_attributes.clear
end

#save!(options = nil) ⇒ Object



47
48
49
50
# File 'lib/sequencescape-api/resource/modifications.rb', line 47

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

#update_attributes!(attributes) ⇒ Object



41
42
43
44
45
# File 'lib/sequencescape-api/resource/modifications.rb', line 41

def update_attributes!(attributes)
  changed_attributes.clear
  update_from_json(attributes, false)
  modify!(:action => :update)
end