Sha256: 5f7369feac37c9b8f59fbc6c3e4e3ce5b14057c82142de2d8044457c5f44442a
Contents?: true
Size: 1.06 KB
Versions: 14
Compression:
Stored size: 1.06 KB
Contents
module ChartMogul module API module Actions module Create def self.included(base) base.extend ClassMethods end def create! resp = handling_errors do connection.post(resource_path.apply(instance_attributes)) do |req| req.headers['Content-Type'] = 'application/json' req.body = JSON.dump(serialize_for_write) end end json = ChartMogul::Utils::JSONParser.parse(resp.body) assign_all_attributes(json) end module ClassMethods def create!(attributes = {}) resource = new(attributes) resp = handling_errors do connection.post(resource_path.apply(attributes)) do |req| req.headers['Content-Type'] = 'application/json' req.body = JSON.dump(resource.serialize_for_write) end end json = ChartMogul::Utils::JSONParser.parse(resp.body) new_from_json(json) end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems