Module: Bronze::Entities::PrimaryKey

Extended by:
SleepingKingStudios::Tools::Toolbox::Mixin
Included in:
Bronze::Entities::PrimaryKeys::Uuid, Bronze::Entity
Defined in:
lib/bronze/entities/primary_key.rb

Overview

Module for defining a primary key attribute on an entity class.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#primary_keyObject

Returns the primary key for the current entity.

Returns:

  • (Object)

    the primary key for the current entity.



62
63
64
65
66
67
68
# File 'lib/bronze/entities/primary_key.rb', line 62

def primary_key
  attribute_name = self.class.primary_key&.name

  return nil unless attribute_name

  get_attribute(attribute_name)
end