Sha256: 5d492f058ee2ec9b02bf019ac48998056779af7d17fcbf9fc30f7b0928b808a8

Contents?: true

Size: 429 Bytes

Versions: 2

Compression:

Stored size: 429 Bytes

Contents

# frozen_string_literal: true

module AbsorbApi
  module Create
    extend ActiveSupport::Concern

    class_methods do
      def create(attributes = {})
        object = new(attributes)
        yield(object) if block_given?

        attrs = object.as_json.transform_keys(&:camelize)
        response = api.post(to_s.demodulize.pluralize.to_s, attrs)
        object.id = response["Id"]
        object
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
absorb_api-0.9.3 lib/absorb_api/create.rb
absorb_api-0.9.2 lib/absorb_api/create.rb