Class Sequel::Model::Associations::ManyToOneAssociationReflection
In: lib/sequel/model/associations.rb
Parent: AssociationReflection

Methods

Public Instance methods

associated_object_keys()

Alias for primary_keys

many_to_one associations can only have associated objects if none of the :keys options have a nil value.

[Source]

     # File lib/sequel/model/associations.rb, line 265
265:         def can_have_associated_objects?(obj)
266:           !self[:keys].any?{|k| obj.send(k).nil?}
267:         end

Whether the dataset needs a primary key to function, false for many_to_one associations.

[Source]

     # File lib/sequel/model/associations.rb, line 270
270:         def dataset_need_primary_key?
271:           false
272:         end

Default foreign key name symbol for foreign key in current model‘s table that points to the given association‘s table‘s primary key.

[Source]

     # File lib/sequel/model/associations.rb, line 276
276:         def default_key
277: 
278:           "#{self[:name]}_id"
279:         end

Whether to eagerly graph a lazy dataset, true for many_to_one associations only if the key is nil.

[Source]

     # File lib/sequel/model/associations.rb, line 282
282:         def eager_graph_lazy_dataset?
283:           self[:key].nil?
284:         end

many_to_one associations don‘t need an eager limit strategy

[Source]

     # File lib/sequel/model/associations.rb, line 287
287:         def eager_limit_strategy
288:           nil
289:         end

The key to use for the key hash when eager loading

[Source]

     # File lib/sequel/model/associations.rb, line 292
292:         def eager_loader_key
293:           cached_fetch(:eager_loader_key){self[:key]}
294:         end

The column(s) in the associated table that the key in the current table references (either a symbol or an array).

[Source]

     # File lib/sequel/model/associations.rb, line 297
297:         def primary_key
298:          cached_fetch(:primary_key){associated_class.primary_key}
299:         end

The method symbol or array of method symbols to call on the associated object to get the value to use for the foreign keys.

[Source]

     # File lib/sequel/model/associations.rb, line 309
309:         def primary_key_method
310:          cached_fetch(:primary_key_method){primary_key}
311:         end

The array of method symbols to call on the associated object to get the value to use for the foreign keys.

[Source]

     # File lib/sequel/model/associations.rb, line 315
315:         def primary_key_methods
316:          cached_fetch(:primary_key_methods){Array(primary_key_method)}
317:         end

The columns in the associated table that the key in the current table references (always an array).

[Source]

     # File lib/sequel/model/associations.rb, line 302
302:         def primary_keys
303:          cached_fetch(:primary_keys){Array(primary_key)}
304:         end

primary_key qualified by the associated table

[Source]

     # File lib/sequel/model/associations.rb, line 320
320:         def qualified_primary_key
321:           cached_fetch(:qualified_primary_key){self[:qualify] == false ? primary_key : qualify_assoc(primary_key)}
322:         end

True only if the reciprocal is a one_to_many association.

[Source]

     # File lib/sequel/model/associations.rb, line 325
325:         def reciprocal_array?
326:           !set_reciprocal_to_self?
327:         end

Whether this association returns an array of objects instead of a single object, false for a many_to_one association.

[Source]

     # File lib/sequel/model/associations.rb, line 331
331:         def returns_array?
332:           false
333:         end

True only if the reciprocal is a one_to_one association.

[Source]

     # File lib/sequel/model/associations.rb, line 336
336:         def set_reciprocal_to_self?
337:           reciprocal
338:           reciprocal_type == :one_to_one
339:         end

[Validate]