Sha256: 636a0380bc9a3de497aafeeedccb773b9e269a13f3c822473257c21d527ce522
Contents?: true
Size: 871 Bytes
Versions: 19
Compression:
Stored size: 871 Bytes
Contents
require 'active_support' require File.dirname(__FILE__) + '/../../proxy' class LHS::Item < LHS::Proxy module Save extend ActiveSupport::Concern def save(options = nil) save!(options) rescue LHC::Error => e self.errors = LHS::Errors.new(e.response) false end def save!(options = {}) options ||= {} record = _data.class data = _data._raw.dup if href.present? url = href else endpoint = record.find_endpoint(data) url = endpoint.compile(data) endpoint.remove_interpolated_params!(data) end options = options.merge(method: :post, url: url, body: data.to_json) options[:headers] ||= {} options[:headers].merge!('Content-Type' => 'application/json') data = record.request(options) _data.merge_raw!(data) true end end end
Version data entries
19 entries across 19 versions & 1 rubygems