Sha256: e07ba80cc0aa3248a07f22feae09442456a711c7491fc2bcb3b54433e563fb30
Contents?: true
Size: 693 Bytes
Versions: 5
Compression:
Stored size: 693 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.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.new(data) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems