Module: Cuprum::Collections::Relation::PrimaryKeys
- Included in:
- Collection, Cuprum::Collections::Resource
- Defined in:
- lib/cuprum/collections/relation.rb
Overview
Methods for specifying a relation’s primary key.
Instance Method Summary collapse
-
#primary_key_name ⇒ String
The name of the primary key attribute.
-
#primary_key_type ⇒ Class, Stannum::Constraint
The type of the primary key attribute.
Instance Method Details
#primary_key_name ⇒ String
Returns the name of the primary key attribute. Defaults to ‘id’.
339 340 341 |
# File 'lib/cuprum/collections/relation.rb', line 339 def primary_key_name @primary_key_name ||= .fetch(:primary_key_name, 'id').to_s end |
#primary_key_type ⇒ Class, Stannum::Constraint
Returns the type of the primary key attribute. Defaults to Integer.
345 346 347 348 349 350 |
# File 'lib/cuprum/collections/relation.rb', line 345 def primary_key_type @primary_key_type ||= .fetch(:primary_key_type, Integer) .then { |obj| obj.is_a?(String) ? Object.const_get(obj) : obj } end |