Module: Cuprum::Collections::Relations::PrimaryKeys
- Included in:
- Collection, Cuprum::Collections::Resource
- Defined in:
- lib/cuprum/collections/relations/primary_keys.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'.
10 11 12 |
# File 'lib/cuprum/collections/relations/primary_keys.rb', line 10 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.
16 17 18 19 20 21 |
# File 'lib/cuprum/collections/relations/primary_keys.rb', line 16 def primary_key_type @primary_key_type ||= .fetch(:primary_key_type, Integer) .then { |obj| obj.is_a?(String) ? Object.const_get(obj) : obj } end |