Sha256: 9a886e81550cf0d11b04626d2cc48a77d28b553535b6fe249caa8b7abbd18617

Contents?: true

Size: 904 Bytes

Versions: 17

Compression:

Stored size: 904 Bytes

Contents

module ActiveRecord
  module AttributeMethods
    module Dirty
      def write_attribute(attr, value)
        # CPK
        # attr = attr.to_s
        attr = attr.to_s unless self.composite?

        # The attribute already has an unsaved change.
        if attribute_changed?(attr)
          old = @changed_attributes[attr]
          @changed_attributes.delete(attr) unless field_changed?(attr, old, value)
        else
          old = clone_attribute_value(:read_attribute, attr)
          # Save Time objects as TimeWithZone if time_zone_aware_attributes == true
          old = old.in_time_zone if clone_with_time_zone_conversion_attribute?(attr, old)
          @changed_attributes[attr] = old if field_changed?(attr, old, value)
        end

        # Carry on.
        super(attr, value)
      end
    end
  end
end

ActiveRecord::Base.class_eval do
  alias :[]= :write_attribute
  public :[]=
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
composite_primary_keys-5.0.4 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-5.0.2 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-5.0.1 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-5.0.0 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-5.0.0.rc1 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.1.2 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.1.1 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta9 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta8 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta7 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta6 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta5 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta4 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta3 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta2 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-4.0.0.beta1 lib/composite_primary_keys/attribute_methods/dirty.rb