diff options
Diffstat (limited to 'activerecord/lib/active_record/type')
5 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/type/binary.rb b/activerecord/lib/active_record/type/binary.rb index 005a48ef0d..412d387c76 100644 --- a/activerecord/lib/active_record/type/binary.rb +++ b/activerecord/lib/active_record/type/binary.rb @@ -23,7 +23,7 @@ module ActiveRecord end def changed_in_place?(raw_old_value, value) - old_value = type_cast_from_database(raw_old_value) + old_value = deserialize(raw_old_value) old_value != value end diff --git a/activerecord/lib/active_record/type/helpers/mutable.rb b/activerecord/lib/active_record/type/helpers/mutable.rb index dc37f4a885..9af39aa9fb 100644 --- a/activerecord/lib/active_record/type/helpers/mutable.rb +++ b/activerecord/lib/active_record/type/helpers/mutable.rb @@ -3,7 +3,7 @@ module ActiveRecord module Helpers module Mutable # :nodoc: def type_cast_from_user(value) - type_cast_from_database(type_cast_for_database(value)) + deserialize(type_cast_for_database(value)) end # +raw_old_value+ will be the `_before_type_cast` version of the diff --git a/activerecord/lib/active_record/type/integer.rb b/activerecord/lib/active_record/type/integer.rb index 2ab2402dfd..b8cbf6114d 100644 --- a/activerecord/lib/active_record/type/integer.rb +++ b/activerecord/lib/active_record/type/integer.rb @@ -16,7 +16,7 @@ module ActiveRecord :integer end - def type_cast_from_database(value) + def deserialize(value) return if value.nil? value.to_i end diff --git a/activerecord/lib/active_record/type/serialized.rb b/activerecord/lib/active_record/type/serialized.rb index 6c6c520048..67aac58b1d 100644 --- a/activerecord/lib/active_record/type/serialized.rb +++ b/activerecord/lib/active_record/type/serialized.rb @@ -11,7 +11,7 @@ module ActiveRecord super(subtype) end - def type_cast_from_database(value) + def deserialize(value) if default_value?(value) value else diff --git a/activerecord/lib/active_record/type/value.rb b/activerecord/lib/active_record/type/value.rb index 7338920f3b..d6b61ead63 100644 --- a/activerecord/lib/active_record/type/value.rb +++ b/activerecord/lib/active_record/type/value.rb @@ -18,7 +18,7 @@ module ActiveRecord # Value#type_cast and Value#cast_value. # # +value+ The raw input, as provided from the database. - def type_cast_from_database(value) + def deserialize(value) type_cast(value) end @@ -73,11 +73,11 @@ module ActiveRecord # # or # - # - pass +raw_old_value+ to Value#type_cast_from_database and compare it to + # - pass +raw_old_value+ to Value#deserialize and compare it to # +new_value+ # # +raw_old_value+ The original value, before being passed to - # +type_cast_from_database+. + # +deserialize+. # # +new_value+ The current value, after type casting. def changed_in_place?(raw_old_value, new_value) @@ -94,7 +94,7 @@ module ActiveRecord private # Convenience method. If you don't need separate behavior for - # Value#type_cast_from_database and Value#type_cast_from_user, you can override + # Value#deserialize and Value#type_cast_from_user, you can override # this method instead. The default behavior of both methods is to call # this one. See also Value#cast_value. def type_cast(value) # :doc: |