Sha256: 996e62e094a8e946f809dfa9bad2ea49e8eee649e1f7011195648f4594b7e868

Contents?: true

Size: 915 Bytes

Versions: 21

Compression:

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

      def id_in_database
        sync_with_transaction_state
        # CPK
        # attribute_in_database(self.class.primary_key)
        if self.composite?
          self.class.primary_keys.map do |key_attr|
            attribute_in_database(key_attr)
          end
        else
          attribute_in_database(self.class.primary_key)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
composite_primary_keys-12.0.2 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.3.1 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-12.0.1 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-12.0.0 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-12.0.0.rc5 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-12.0.0.rc4 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-12.0.0.rc3 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-12.0.0.rc2 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-12.0.0.rc1 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.2.0 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.1.0 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.3 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.2 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.1 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.0 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.0.rc2 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.0.rc1 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.0.beta4 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.0.beta3 lib/composite_primary_keys/attribute_methods/primary_key.rb
composite_primary_keys-11.0.0.beta2 lib/composite_primary_keys/attribute_methods/primary_key.rb