Module: ActiveRecord::Type::Numeric
Overview
:nodoc:
Instance Method Summary collapse
-
#changed?(old_value, _new_value, new_value_before_type_cast) ⇒ Boolean
:nodoc:.
- #number? ⇒ Boolean
- #type_cast(value) ⇒ Object
Instance Method Details
#changed?(old_value, _new_value, new_value_before_type_cast) ⇒ Boolean
:nodoc:
18 19 20 |
# File 'lib/active_record/type/numeric.rb', line 18 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 |
#type_cast(value) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/active_record/type/numeric.rb', line 8 def type_cast(value) value = case value when true then 1 when false then 0 when ::String then value.presence else value end super(value) end |