Sha256: 42b937d2991220905a986ce812f7c7a9eb1f9d258cc33688cfea2d39661e7cc9
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chartmogul-ruby-1.1.5 | lib/chartmogul/api/actions/create.rb |