16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/lhs/concerns/item/save.rb', line 16
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
|