Sha256: 44c0f3972fbe9d6a30b8dc0c1c5869e8896390aa6046db2ed6e34218d18a9d49

Contents?: true

Size: 545 Bytes

Versions: 9

Compression:

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

9 entries across 9 versions & 1 rubygems

Version Path
composite_primary_keys-7.0.16 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-7.0.15 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.1 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-7.0.14 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.1.0 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-7.0.13 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-8.0.0 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-7.0.12 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-7.0.11 lib/composite_primary_keys/attribute_methods/primary_key.rb