Sha256: c890195823b43d31fd9dd987e14094dedd320b9dcb8bc676e2794b042dc9f35e
Contents?: true
Size: 889 Bytes
Versions: 2
Compression:
Stored size: 889 Bytes
Contents
# The LooserTypecasting extension changes the float and integer typecasting to # use the looser .to_f and .to_i instead of the more strict Kernel.Float and # Kernel.Integer. To load the extension into the database: # # DB.extension :looser_typecasting module Sequel module LooserTypecasting # Typecast the value to a Float using to_f instead of Kernel.Float def typecast_value_float(value) value.to_f end # Typecast the value to an Integer using to_i instead of Kernel.Integer def typecast_value_integer(value) value.to_i end # Typecast the value to a BigDecimal, without checking if strings # have a valid format. def typecast_value_decimal(value) if value.is_a?(String) BigDecimal.new(value) else super end end end Database.register_extension(:looser_typecasting, LooserTypecasting) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sequel-3.47.0 | lib/sequel/extensions/looser_typecasting.rb |
sequel-3.46.0 | lib/sequel/extensions/looser_typecasting.rb |