Module: DHS::Item::Update
- Extended by:
- ActiveSupport::Concern
- Included in:
- DHS::Item
- Defined in:
- lib/dhs/concerns/item/update.rb
Instance Method Summary collapse
- #partial_update(params, options = nil) ⇒ Object
- #partial_update!(params, options = nil) ⇒ Object
- #update(params, options = nil, partial_update = false) ⇒ Object
- #update!(params, options = {}, partial_update = false) ⇒ Object
Instance Method Details
#partial_update(params, options = nil) ⇒ Object
23 24 25 |
# File 'lib/dhs/concerns/item/update.rb', line 23 def partial_update(params, = nil) update(params, , true) end |
#partial_update!(params, options = nil) ⇒ Object
27 28 29 |
# File 'lib/dhs/concerns/item/update.rb', line 27 def partial_update!(params, = nil) update!(params, , true) end |
#update(params, options = nil, partial_update = false) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/dhs/concerns/item/update.rb', line 16 def update(params, = nil, partial_update = false) update!(params, , partial_update) rescue DHC::Error => e self.errors = DHS::Problems::Errors.new(e.response, record) false end |
#update!(params, options = {}, partial_update = false) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/dhs/concerns/item/update.rb', line 31 def update!(params, = {}, partial_update = false) = .present? ? .dup : {} partial_record = _record.new(DHS::Data.new(params, _data.parent, _record)) _data.merge_raw!(partial_record._data) data = _data._raw.dup partial_data = partial_record._data._raw.dup url = url_for_persistance!(data, ) data_sent = partial_update ? partial_data.extract!(*data.keys) : data response_data = record.request( .merge( method: .fetch(:method, :post), url: url, body: data_sent ) ) _data.merge_raw!(response_data.unwrap(:item_created_key)) true end |