Module: LHS::Item::Save

Extended by:
ActiveSupport::Concern
Included in:
LHS::Item
Defined in:
lib/lhs/concerns/item/save.rb

Instance Method Summary collapse

Instance Method Details

#save(options = nil) ⇒ Object



16
17
18
19
20
# File 'lib/lhs/concerns/item/save.rb', line 16

def save(options = nil)
  save!(options)
rescue LHC::Error
  false
end

#save!(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lhs/concerns/item/save.rb', line 22

def save!(options = {})
  options = options.present? ? options.dup : {}
  data = _data._raw.dup
  url = url_for_persistance!(data, options)
  create_and_merge_data!(
    apply_default_creation_options(options, url, data)
  )
rescue LHC::Error => e
  self.errors = LHS::Problems::Errors.new(e.response, record)
  raise e
end