module ActiveRecord::AttributeMethods::PrimaryKey

def attribute_method?(attr_name)

def attribute_method?(attr_name)
  attr_name == 'id' || super
end

def id

Returns the primary key value.
def id
  if pk = self.class.primary_key
    sync_with_transaction_state
    _read_attribute(pk)
  end
end

def id=(value)

Sets the primary key value.
def id=(value)
  sync_with_transaction_state
  write_attribute(self.class.primary_key, value) if self.class.primary_key
end

def id?

Queries the primary key value.
def id?
  sync_with_transaction_state
  query_attribute(self.class.primary_key)
end

def id_before_type_cast

Returns the primary key value before type cast.
def id_before_type_cast
  sync_with_transaction_state
  read_attribute_before_type_cast(self.class.primary_key)
end

def id_was

Returns the primary key previous value.
def id_was
  sync_with_transaction_state
  attribute_was(self.class.primary_key)
end

def to_key

available.
Returns this record's primary key value wrapped in an Array if one is
def to_key
  sync_with_transaction_state
  key = self.id
  [key] if key
end