Module: Sequel::LooserTypecasting

Defined in:
lib/sequel/extensions/looser_typecasting.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) typecast_value_decimal(value)

Typecast the value to a BigDecimal, without checking if strings have a valid format.



32
33
34
35
36
37
38
# File 'lib/sequel/extensions/looser_typecasting.rb', line 32

def typecast_value_decimal(value)
  if value.is_a?(String)
    BigDecimal.new(value)
  else
    super
  end
end

- (Object) typecast_value_float(value)

Typecast the value to a Float using to_f instead of Kernel.Float



16
17
18
# File 'lib/sequel/extensions/looser_typecasting.rb', line 16

def typecast_value_float(value)
  value.to_f
end

- (Object) typecast_value_integer(value)

Typecast the value to an Integer using to_i instead of Kernel.Integer



21
22
23
# File 'lib/sequel/extensions/looser_typecasting.rb', line 21

def typecast_value_integer(value)
  value.to_i
end

- (Object) typecast_value_string(value)

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_string(value)
  value.to_s
end