Module: DataMapper::Property::Typecast::Numeric
Instance Method Summary collapse
-
#typecast_to_numeric(value, method) ⇒ Numeric
private
Match numeric string.
Instance Method Details
#typecast_to_numeric(value, method) ⇒ Numeric
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.
Match numeric string
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dm-core/property/typecast/numeric.rb', line 16 def typecast_to_numeric(value, method) if value.respond_to?(:to_str) if value.to_str =~ /\A(-?(?:0|[1-9]\d*)(?:\.\d+)?|(?:\.\d+))\z/ $1.send(method) else value end elsif value.respond_to?(method) value.send(method) else value end end |