Sha256: d6bc712c7340f38672cc83c0968a0ea279ea0460dde7256425bb1861184f10f0

Contents?: true

Size: 640 Bytes

Versions: 11

Compression:

Stored size: 640 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)
      _data.merge_raw!(LHS::Data.new(params, _data.parent, _data.class))
      response_data = _data.class.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

11 entries across 11 versions & 1 rubygems

Version Path
lhs-5.0.4 lib/lhs/concerns/item/update.rb
lhs-5.0.3 lib/lhs/concerns/item/update.rb
lhs-5.0.1 lib/lhs/concerns/item/update.rb
lhs-5.0.0 lib/lhs/concerns/item/update.rb
lhs-4.2.1 lib/lhs/concerns/item/update.rb
lhs-4.2.0 lib/lhs/concerns/item/update.rb
lhs-4.1.0 lib/lhs/concerns/item/update.rb
lhs-4.0.0 lib/lhs/concerns/item/update.rb
lhs-3.4.2 lib/lhs/concerns/item/update.rb
lhs-3.4.1 lib/lhs/concerns/item/update.rb
lhs-3.4.0 lib/lhs/concerns/item/update.rb