aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type/helpers/mutable.rb
blob: 88a90992772db52ead0dbfdf33e4a3c4707c42a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module ActiveRecord
  module Type
    module Helpers
      module Mutable # :nodoc:
        def cast(value)
          deserialize(serialize(value))
        end

        # +raw_old_value+ will be the `_before_type_cast` version of the
        # value (likely a string). +new_value+ will be the current, type
        # cast value.
        def changed_in_place?(raw_old_value, new_value)
          raw_old_value != serialize(new_value)
        end
      end
    end
  end
end