Sha256: f4d616e031b640a6e9401f2711bbdc2da2846a30e0aebf7021688a31ae05256b
Contents?: true
Size: 705 Bytes
Versions: 15
Compression:
Stored size: 705 Bytes
Contents
require 'active_support' class LHS::Record module Create extend ActiveSupport::Concern module ClassMethods def create(data = {}) create!(data) rescue LHC::Error => e json = JSON.parse(data.to_json) data = LHS::Data.new(json, nil, self, e.response.request) item = LHS::Item.new(data) item.errors = LHS::Errors.new(e.response) data._record_class.new(LHS::Data.new(item, data)) end def create!(data = {}) url = compute_url!(data) data = request(url: url, method: :post, body: data.to_json, headers: { 'Content-Type' => 'application/json' }) data._record_class.new(data) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems