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

### Methods

associated_object_keys can_have_associated_objects? default_key eager_loader_key primary_key reciprocal_array? remove_before_destroy? remove_should_check_existing? set_reciprocal_to_self?

### Public Instance methods

associated_object_keys()

The keys in the associated model‘s table related to this association

[Source]

         # File lib/sequel/model/associations.rb, line 242
    242:         def associated_object_keys
    243:           self[:keys]
    244:         end

can_have_associated_objects?(obj)

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

[Source]

         # File lib/sequel/model/associations.rb, line 248
    248:         def can_have_associated_objects?(obj)
    249:           !self[:primary_keys].any?{|k| obj.send(k).nil?}
    250:         end

default_key()

Default foreign key name symbol for key in associated table that points to current table‘s primary key.

[Source]

         # File lib/sequel/model/associations.rb, line 254
    254:         def default_key
    255:
    256:           "#{underscore(demodulize(self[:model].name))}_id"
    257:         end

eager_loader_key()

The key to use for the key hash when eager loading

[Source]

         # File lib/sequel/model/associations.rb, line 259
    259:         def eager_loader_key
    260:           self[:eager_loader_key] ||= primary_key
    261:         end

primary_key()

The column in the current table that the key in the associated table references.

[Source]

         # File lib/sequel/model/associations.rb, line 264
    264:         def primary_key
    265:          self[:primary_key] ||= self[:model].primary_key
    266:         end

reciprocal_array?()

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

[Source]

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

remove_before_destroy?()

Destroying one_to_many associated objects automatically deletes the foreign key.

[Source]

         # File lib/sequel/model/associations.rb, line 275
    275:         def remove_before_destroy?
    276:           false
    277:         end

remove_should_check_existing?()

The one_to_many association needs to check that an object to be removed already is associated.

[Source]

         # File lib/sequel/model/associations.rb, line 280
    280:         def remove_should_check_existing?
    281:           true
    282:         end

set_reciprocal_to_self?()

One to many associations set the reciprocal to self when loading associated records.

[Source]

         # File lib/sequel/model/associations.rb, line 285
    285:         def set_reciprocal_to_self?
    286:           true
    287:         end

[Validate]