module JSONAPI::Record::Creatable

Public Class Methods

included(base) click to toggle source
# File lib/jsonapi/record/creatable.rb, line 6
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

creatable_attributes() click to toggle source

Returns the attributes for creating a resource. @return [Hash]

# File lib/jsonapi/record/creatable.rb, line 56
def creatable_attributes
  attributes.slice(*self.class.creatable_attribute_names)
end
payload_attributes() click to toggle source

Override payload_attributes

# File lib/jsonapi/record/creatable.rb, line 61
def payload_attributes
  payload_attributes_for_create
end
payload_attributes_for_create() click to toggle source

Returns the attributes for the payload for post request. @return [Hash] if there are creatable attributes. @return [nil] if there are no creatable attributes.

# File lib/jsonapi/record/creatable.rb, line 68
def payload_attributes_for_create
  creatable_attributes if creatable_attributes.any?
end