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

### Methods

associated_object_keys can_have_associated_objects? dataset_need_primary_key? default_key eager_graph_lazy_dataset? eager_limit_strategy predicate_key primary_key primary_key_method primary_key_methods primary_keys qualified_primary_key reciprocal_array? returns_array? set_reciprocal_to_self?

### Public Instance methods

associated_object_keys()

Alias for primary_keys

can_have_associated_objects?(obj)

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 288
    288:         def can_have_associated_objects?(obj)
    289:           !self[:keys].any?{|k| obj.send(k).nil?}
    290:         end

dataset_need_primary_key?()

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

[Source]

         # File lib/sequel/model/associations.rb, line 293
    293:         def dataset_need_primary_key?
    294:           false
    295:         end

default_key()

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 299
    299:         def default_key
    300:
    301:           "#{self[:name]}_id"
    302:         end

eager_graph_lazy_dataset?()

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 305
    305:         def eager_graph_lazy_dataset?
    306:           self[:key].nil?
    307:         end

eager_limit_strategy()

many_to_one associations don‘t need an eager limit strategy

[Source]

         # File lib/sequel/model/associations.rb, line 310
    310:         def eager_limit_strategy
    311:           nil
    312:         end

predicate_key()

The expression to use on the left hand side of the IN lookup when eager loading

[Source]

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

primary_key()

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 320
    320:         def primary_key
    321:          cached_fetch(:primary_key){associated_class.primary_key}
    322:         end

primary_key_method()

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 332
    332:         def primary_key_method
    333:          cached_fetch(:primary_key_method){primary_key}
    334:         end

primary_key_methods()

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 338
    338:         def primary_key_methods
    339:          cached_fetch(:primary_key_methods){Array(primary_key_method)}
    340:         end

primary_keys()

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 325
    325:         def primary_keys
    326:          cached_fetch(:primary_keys){Array(primary_key)}
    327:         end

qualified_primary_key()

primary_key qualified by the associated table

[Source]

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

reciprocal_array?()

True only if the reciprocal is a one_to_many association.

[Source]

         # File lib/sequel/model/associations.rb, line 348
    348:         def reciprocal_array?
    349:           !set_reciprocal_to_self?
    350:         end

returns_array?()

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 354
    354:         def returns_array?
    355:           false
    356:         end

set_reciprocal_to_self?()

True only if the reciprocal is a one_to_one association.

[Source]

         # File lib/sequel/model/associations.rb, line 359
    359:         def set_reciprocal_to_self?
    360:           reciprocal
    361:           reciprocal_type == :one_to_one
    362:         end

[Validate]