Sha256: 34a139b24b2f2faf1b6161ed298a12fa7364c5578c33c56ab8e253c1b0402a96
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 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(self.instance_attributes)) do |req| req.headers['Content-Type'] = 'application/json' req.body = JSON.dump(self.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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chartmogul-ruby-1.1.4 | lib/chartmogul/api/actions/create.rb |
chartmogul-ruby-1.1.2 | lib/chartmogul/api/actions/create.rb |