Sha256: 1aadcad88a2790be15baee04e45802dff437271ed60c5a277eb1c2b85f0a6eb4

Contents?: true

Size: 653 Bytes

Versions: 6

Compression:

Stored size: 653 Bytes

Contents

require 'active_support'
require File.dirname(__FILE__) + '/../../proxy'

class LHS::Item < LHS::Proxy

  module Update
    extend ActiveSupport::Concern

    def update(params)
      update!(params)
    rescue LHC::Error => e
      self.errors = LHS::Errors.new(e.response)
      false
    end

    def update!(params)
      service = _data._root._service
      _data.merge_raw!(LHS::Data.new(params))
      response_data = service.instance.request(
        method: :post,
        url: href,
        body: _data.to_json,
        headers: {'Content-Type' => 'application/json'}
      )
      _data.merge_raw!(response_data)
      true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lhs-2.0.5 lib/lhs/concerns/item/update.rb
lhs-2.0.4 lib/lhs/concerns/item/update.rb
lhs-2.0.3 lib/lhs/concerns/item/update.rb
lhs-2.0.2 lib/lhs/concerns/item/update.rb
lhs-2.0.1 lib/lhs/concerns/item/update.rb
lhs-2.0.0 lib/lhs/concerns/item/update.rb