Module: Sequel::LooserTypecasting
- Defined in:
- lib/sequel/extensions/looser_typecasting.rb
Instance Method Summary collapse
-
#typecast_value_decimal(value) ⇒ Object
Typecast the value to a BigDecimal, without checking if strings have a valid format.
-
#typecast_value_float(value) ⇒ Object
Typecast the value to a Float using to_f instead of Kernel.Float.
-
#typecast_value_integer(value) ⇒ Object
Typecast the value to an Integer using to_i instead of Kernel.Integer.
-
#typecast_value_string(value) ⇒ Object
Typecast the value to an String using to_s instead of Kernel.String.
Instance Method Details
#typecast_value_decimal(value) ⇒ Object
Typecast the value to a BigDecimal, without checking if strings have a valid format.
37 38 39 40 41 42 43 |
# File 'lib/sequel/extensions/looser_typecasting.rb', line 37 def typecast_value_decimal(value) if value.is_a?(String) BigDecimal.new(value) else super end end |
#typecast_value_float(value) ⇒ Object
Typecast the value to a Float using to_f instead of Kernel.Float
21 22 23 |
# File 'lib/sequel/extensions/looser_typecasting.rb', line 21 def typecast_value_float(value) value.to_f end |
#typecast_value_integer(value) ⇒ Object
Typecast the value to an Integer using to_i instead of Kernel.Integer
26 27 28 |
# File 'lib/sequel/extensions/looser_typecasting.rb', line 26 def typecast_value_integer(value) value.to_i end |
#typecast_value_string(value) ⇒ Object
Typecast the value to an String using to_s instead of Kernel.String
31 32 33 |
# File 'lib/sequel/extensions/looser_typecasting.rb', line 31 def typecast_value_string(value) value.to_s end |