Sha256: 86562a6b9702e0d76135c746bfc5206b0699d2683c6854cb0a83ca8189547a2b
Contents?: true
Size: 673 Bytes
Versions: 20
Compression:
Stored size: 673 Bytes
Contents
require 'active_support' class LHS::Service 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.class, e.response.request) item = LHS::Item.new(data) item.errors = LHS::Errors.new(e.response) LHS::Data.new(item, data) end def create!(data = {}) url = instance.compute_url!(data) instance.request(url: url, method: :post, body: data.to_json, headers: {'Content-Type' => 'application/json'}) end end end end
Version data entries
20 entries across 20 versions & 1 rubygems