Class: Cuprum::Collections::Associations::BelongsTo
- Inherits:
-
Cuprum::Collections::Association
- Object
- Relation
- Resource
- Cuprum::Collections::Association
- Cuprum::Collections::Associations::BelongsTo
- Defined in:
- lib/cuprum/collections/associations/belongs_to.rb
Overview
Object representing a belongs_to association, which inverts the foreign key.
Instance Attribute Summary
Attributes inherited from Cuprum::Collections::Association
Attributes inherited from Relation
Attributes included from Relation::Parameters
#name, #plural_name, #qualified_name, #singular_name
Instance Method Summary collapse
-
#initialize(entity_class: nil, name: nil, qualified_name: nil, singular_name: nil, **options) ⇒ BelongsTo
constructor
A new instance of BelongsTo.
-
#primary_key_query? ⇒ Boolean
True if the association queries by primary key, e.g.
Methods inherited from Cuprum::Collections::Association
#association_class, #association_name, #build_entities_query, #build_keys_query, #foreign_key_name, #inverse_class, #inverse_key_name, #inverse_name, #map_entities_to_keys, #query_key_name, #singular_inverse_name, #with_inverse
Methods inherited from Resource
#resource_class, #resource_name, #singular_resource_name
Methods included from Relation::PrimaryKeys
#primary_key_name, #primary_key_type
Methods included from Relation::Disambiguation
disambiguate_keyword, #disambiguate_keyword, resolve_parameters, #resolve_parameters
Methods included from Relation::Cardinality
Methods included from Relation::Parameters
#entity_class, resolve_parameters, #resolve_parameters
Constructor Details
#initialize(entity_class: nil, name: nil, qualified_name: nil, singular_name: nil, **options) ⇒ BelongsTo
Returns a new instance of BelongsTo.
10 11 12 13 14 15 |
# File 'lib/cuprum/collections/associations/belongs_to.rb', line 10 def initialize(**params) params.delete(:plural) params.delete(:singular) super(**params, singular: true) end |
Instance Method Details
#primary_key_query? ⇒ Boolean
Returns true if the association queries by primary key, e.g. a :belongs_to association; false if the association queries by foreign key, e.g. a :has_one or :has_many association.
18 19 20 |
# File 'lib/cuprum/collections/associations/belongs_to.rb', line 18 def primary_key_query? true end |