class Sequel::Plugins::PgArrayAssociations::ManyToPgArrayAssociationReflection

The AssociationReflection subclass for many_to_pg_array associations.

Public Instance Methods

associated_object_keys() click to toggle source

The array column in the associated model containing foreign keys to the current model.

# File lib/sequel/plugins/pg_array_associations.rb, line 77
def associated_object_keys
  [self[:key]]
end
can_have_associated_objects?(obj) click to toggle source

many_to_pg_array associations can have associated objects as long as they have a primary key.

# File lib/sequel/plugins/pg_array_associations.rb, line 83
def can_have_associated_objects?(obj)
  obj.send(self[:primary_key])
end
default_key() click to toggle source

Assume that the key in the associated table uses a version of the current model's name suffixed with _ids.

# File lib/sequel/plugins/pg_array_associations.rb, line 89
def default_key
  :"#{underscore(demodulize(self[:model].name))}_ids"
end
predicate_key() click to toggle source

The hash key to use for the eager loading predicate (left side of IN (1, 2, 3))

# File lib/sequel/plugins/pg_array_associations.rb, line 94
def predicate_key
  cached_fetch(:predicate_key){qualify_assoc(self[:key_column])}
end
primary_key() click to toggle source

The column in the current table that the keys in the array column in the associated table reference.

# File lib/sequel/plugins/pg_array_associations.rb, line 100
def primary_key
  self[:primary_key]
end
remove_before_destroy?() click to toggle source

Destroying the associated object automatically removes the association, since the association is stored in the associated object.

# File lib/sequel/plugins/pg_array_associations.rb, line 106
def remove_before_destroy?
  false
end

Private Instance Methods

reciprocal_association?(assoc_reflect) click to toggle source

Only consider an association as a reciprocal if it has matching keys and primary keys.

# File lib/sequel/plugins/pg_array_associations.rb, line 114
def reciprocal_association?(assoc_reflect)
  super && self[:key] == assoc_reflect[:key] && primary_key == assoc_reflect.primary_key
end
reciprocal_type() click to toggle source
# File lib/sequel/plugins/pg_array_associations.rb, line 118
def reciprocal_type
  :pg_array_to_many
end