Class: JsonApiClient::Schema::Property

Inherits:
Struct
  • Object
show all
Defined in:
lib/json_api_client/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultObject

Returns the value of attribute default

Returns:

  • (Object)

    the current value of default



98
99
100
# File 'lib/json_api_client/schema.rb', line 98

def default
  @default
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



98
99
100
# File 'lib/json_api_client/schema.rb', line 98

def name
  @name
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



98
99
100
# File 'lib/json_api_client/schema.rb', line 98

def type
  @type
end

Instance Method Details

#cast(value) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/json_api_client/schema.rb', line 99

def cast(value)
  return nil if value.nil?
  return value if type.nil?
  type_caster = TypeFactory.type_for(type)
  return value if type_caster.nil?
  type_caster.cast(value, default)
end