aboutsummaryrefslogblamecommitdiffstats
path: root/activemodel/lib/active_model/type/helpers/mutable.rb
blob: 1cbea644c4a0393c24039049f33daa91730a71e2 (plain) (tree)
1
2
3
4
5
6
7
8

                             
                  
             

                                
                       
                                       





                                                                        
                                               




           
# frozen_string_literal: true

module ActiveModel
  module Type
    module Helpers # :nodoc: all
      module Mutable
        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