Sha256: 930bbe0063c0437cc1bf842f3ba22135de96e03d7e924edc8c2b742f4b115928

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 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

3 entries across 3 versions & 1 rubygems

Version Path
composite_primary_keys-7.0.16 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-7.0.15 lib/composite_primary_keys/attribute_methods/dirty.rb
composite_primary_keys-7.0.14 lib/composite_primary_keys/attribute_methods/dirty.rb