lib/acfs/resource/attributes/float.rb in acfs-0.45.0 vs lib/acfs/resource/attributes/float.rb in acfs-0.46.0
- old
+ new
@@ -11,13 +11,21 @@
class Float < Base
# @api public
#
# Cast given object to float.
#
- # @param [Object] obj Object to cast.
+ # @param [Object] value Object to cast.
# @return [Float] Casted object as float.
#
- def cast_type(obj)
- Float obj
+ def cast_value(value)
+ return 0.0 if value.blank?
+
+ case value
+ when ::Float then value
+ when "Infinity" then ::Float::INFINITY
+ when "-Infinity" then -::Float::INFINITY
+ when "NaN" then ::Float::NAN
+ else Float(value)
+ end
end
end
end