Sha256: cd9ba14cbeccef8449f23e87f759ef9dc0aeae3fe566ec2f5e2aa07a834ef360

Contents?: true

Size: 644 Bytes

Versions: 5

Compression:

Stored size: 644 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.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

5 entries across 5 versions & 1 rubygems

Version Path
lhs-2.2.2 lib/lhs/concerns/item/update.rb
lhs-2.2.1 lib/lhs/concerns/item/update.rb
lhs-2.2.0 lib/lhs/concerns/item/update.rb
lhs-2.1.1 lib/lhs/concerns/item/update.rb
lhs-2.1.0 lib/lhs/concerns/item/update.rb