Sha256: b8e0e5954f296f8f8fa9545de893a3feb51949afa44739ad46b207ff875c104a

Contents?: true

Size: 587 Bytes

Versions: 6

Compression:

Stored size: 587 Bytes

Contents

# frozen_string_literal: true

module ActiveModel
  module Type
    module Helpers # :nodoc: all
      module Mutable
        def immutable_value(value)
          value.deep_dup.freeze
        end

        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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activemodel-7.0.5.1/lib/active_model/type/helpers/mutable.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activemodel-7.0.5.1/lib/active_model/type/helpers/mutable.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activemodel-7.0.5.1/lib/active_model/type/helpers/mutable.rb
activemodel-7.0.6 lib/active_model/type/helpers/mutable.rb
activemodel-7.0.5.1 lib/active_model/type/helpers/mutable.rb
activemodel-7.0.5 lib/active_model/type/helpers/mutable.rb