Module: ActiveModelPersistence::PrimaryKeyIndex::ClassMethods
- Defined in:
- lib/active_model_persistence/primary_key_index.rb
Overview
When this module is included in another class, ActiveSupport::Concern will make these class methods on that class.
Class Method Summary collapse
-
.extended(base) ⇒ void
private
Create the primary key index.
Instance Method Summary collapse
-
#find(primary_key_value) ⇒ Object?
Finds an object in the :primary_key index whose primary matches the given value.
Class Method Details
.extended(base) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Create the primary key index
49 50 51 |
# File 'lib/active_model_persistence/primary_key_index.rb', line 49 def self.extended(base) base.index('primary_key', key_value_source: :primary_key, unique: true) end |
Instance Method Details
#find(primary_key_value) ⇒ Object?
Finds an object in the :primary_key index whose primary matches the given value
39 40 41 |
# File 'lib/active_model_persistence/primary_key_index.rb', line 39 def find(primary_key_value) find_by_primary_key(primary_key_value).first end |