Sha256: 0a76cd67e1d889e741c0c597aa939888e36154884998d0c7d62b511c4e717c1c

Contents?: true

Size: 740 Bytes

Versions: 4

Compression:

Stored size: 740 Bytes

Contents

module ActiveRecord
  module AttributeMethods
    module Dirty
      def write_attribute(attr, value)
        # CPK
        if attr.kind_of?(Array)
          # A *composite* attribute can't be marked as changed! So do nothing now.
          # We will come back in here with an *individual* attribute when Write#write_attribute looks through the individual attributes comprising this composite key:
          # [attr_name, value].transpose.map {|name,val| write_attribute(name, val)}
        else
          attr = attr.to_s

          save_changed_attribute(attr, value)
        end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
composite_primary_keys-7.0.13 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-7.0.12 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-7.0.11 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-7.0.10 lib/composite_primary_keys/attribute_methods/dirty.rb