Class: Morf::Casters::FloatCaster
- Inherits:
-
Object
- Object
- Morf::Casters::FloatCaster
- Defined in:
- lib/morf/casters/float_caster.rb
Class Method Summary collapse
Class Method Details
.cast(value, attr_name, options = {}) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/morf/casters/float_caster.rb', line 2 def self.cast(value, attr_name, = {}) if value.is_a?(Float) value elsif value.is_a?(String) begin Float(value) rescue ArgumentError => e raise Morf::Errors::CastingError, "is invalid float" end else raise Morf::Errors::CastingError, "should be a float" end end |