Class: JSONAPI::Deserializable::Resource::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/deserializable/resource/configuration.rb

Constant Summary collapse

DEFAULT_TYPE_BLOCK =
proc { |t| { type: t } }
DEFAULT_ID_BLOCK =
proc { |i| { id: i } }
DEFAULT_ATTR_BLOCK =
proc { |k, v| { k.to_sym => v } }
DEFAULT_HAS_ONE_BLOCK =
proc do |k, _, i, t|
  { "#{k}_id".to_sym => i, "#{k}_type".to_sym => t }
end
DEFAULT_HAS_MANY_BLOCK =
proc do |k, _, i, t|
  { "#{k}_ids".to_sym => i, "#{k}_types".to_sym => t }
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



18
19
20
21
22
23
24
# File 'lib/jsonapi/deserializable/resource/configuration.rb', line 18

def initialize
  self.default_type       = DEFAULT_TYPE_BLOCK
  self.default_id         = DEFAULT_ID_BLOCK
  self.default_attribute  = DEFAULT_ATTR_BLOCK
  self.default_has_one    = DEFAULT_HAS_ONE_BLOCK
  self.default_has_many   = DEFAULT_HAS_MANY_BLOCK
end

Instance Attribute Details

#default_attributeObject

Returns the value of attribute default_attribute.



15
16
17
# File 'lib/jsonapi/deserializable/resource/configuration.rb', line 15

def default_attribute
  @default_attribute
end

#default_has_manyObject

Returns the value of attribute default_has_many.



15
16
17
# File 'lib/jsonapi/deserializable/resource/configuration.rb', line 15

def default_has_many
  @default_has_many
end

#default_has_oneObject

Returns the value of attribute default_has_one.



15
16
17
# File 'lib/jsonapi/deserializable/resource/configuration.rb', line 15

def default_has_one
  @default_has_one
end

#default_idObject

Returns the value of attribute default_id.



15
16
17
# File 'lib/jsonapi/deserializable/resource/configuration.rb', line 15

def default_id
  @default_id
end

#default_typeObject

Returns the value of attribute default_type.



15
16
17
# File 'lib/jsonapi/deserializable/resource/configuration.rb', line 15

def default_type
  @default_type
end