Class: ActiveAttr::Typecasting::FloatTypecaster
- Inherits:
-
Object
- Object
- ActiveAttr::Typecasting::FloatTypecaster
- Defined in:
- lib/active_attr/typecasting/float_typecaster.rb
Overview
Typecasts an Object to a Float
Instance Method Summary collapse
-
#call(value) ⇒ Float?
Typecasts an object to a Float.
Instance Method Details
#call(value) ⇒ Float?
Typecasts an object to a Float
Attempts to convert using #to_f.
24 25 26 |
# File 'lib/active_attr/typecasting/float_typecaster.rb', line 24 def call(value) value.to_f if value.present? && value.respond_to?(:to_f) end |