Class: JsonApiClient::Schema::Property
- Inherits:
-
Struct
- Object
- Struct
- JsonApiClient::Schema::Property
- Defined in:
- lib/json_api_client/schema.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#name ⇒ Object
Returns the value of attribute name.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default
3 4 5 |
# File 'lib/json_api_client/schema.rb', line 3 def default @default end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/json_api_client/schema.rb', line 3 def name @name end |
#type ⇒ Object
Returns the value of attribute type
3 4 5 |
# File 'lib/json_api_client/schema.rb', line 3 def type @type end |
Instance Method Details
#cast(value) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/json_api_client/schema.rb', line 4 def cast(value) return nil if value.nil? return value if type.nil? case type.to_sym when :int, :integer value.to_i when :string value.to_s when :float value.to_f when :time value.is_a?(Time) || nil ? value : Time.parse(value) when :boolean case value when "false", "0", 0, false false when "true", "1", 1, true true else # if it's unknown, use the default value default end else value end end |