Module: ActiveModel::Type::Helpers::Numeric
Overview
:nodoc:
Instance Method Summary collapse
- #cast(value) ⇒ Object
-
#changed?(old_value, _new_value, new_value_before_type_cast) ⇒ Boolean
:nodoc:.
Instance Method Details
#cast(value) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/active_model/type/helpers/numeric.rb', line 5 def cast(value) value = case value when true then 1 when false then 0 when ::String then value.presence else value end super(value) end |
#changed?(old_value, _new_value, new_value_before_type_cast) ⇒ Boolean
:nodoc:
15 16 17 |
# File 'lib/active_model/type/helpers/numeric.rb', line 15 def changed?(old_value, _new_value, new_value_before_type_cast) # :nodoc: super || number_to_non_number?(old_value, new_value_before_type_cast) end |