Class: Virtus::Attributes::Decimal
- Defined in:
- lib/virtus/attributes/decimal.rb
Constant Summary
Constants inherited from Attribute
Attribute::DEFAULT_ACCESSOR, Attribute::OPTIONS
Instance Attribute Summary
Attributes inherited from Attribute
#instance_variable_name, #model, #name, #options, #reader_visibility, #writer_visibility
Instance Method Summary collapse
-
#typecast_to_primitive(value, model = nil) ⇒ BigDecimal
private
Typecast a value to a BigDecimal.
Methods included from Typecast::Numeric
Methods inherited from Attribute
#_create_reader, #_create_writer, accept_options, accepted_options, #complex?, descendants, #get, #get!, inherited, #initialize, options, #primitive?, #set, #set!, #typecast
Constructor Details
This class inherits a constructor from Virtus::Attributes::Attribute
Instance Method Details
#typecast_to_primitive(value, model = nil) ⇒ BigDecimal
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Typecast a value to a BigDecimal
15 16 17 18 19 20 21 |
# File 'lib/virtus/attributes/decimal.rb', line 15 def typecast_to_primitive(value, model = nil) if value.kind_of?(::Integer) value.to_s.to_d else typecast_to_numeric(value, :to_d) end end |