Sha256: 1b3c73fdcd6cc9dda3467774c04f492882b287c16e3835bcb35fae99b02cd3a0

Contents?: true

Size: 544 Bytes

Versions: 7

Compression:

Stored size: 544 Bytes

Contents

module ActiveRecord
  module AttributeMethods
    module PrimaryKey
      # Returns the primary key previous value.
      def id_was
        sync_with_transaction_state
        # CPK
        # attribute_was(self.class.primary_key)
        if self.composite?
          self.class.primary_keys.map do |key_attr|
            attribute_changed?(key_attr) ? changed_attributes[key_attr] : self.ids_hash[key_attr]
          end
        else
          attribute_was(self.class.primary_key)
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
composite_primary_keys-8.1.8 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.7 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.6 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.5 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.4 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.3 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.2 lib/composite_primary_keys/attribute_methods/primary_key.rb