class Sequel::Plugins::PgArrayAssociations::ManyToPgArrayAssociationReflection

The AssociationReflection subclass for many_to_pg_array associations.

Constants

FINALIZE_SETTINGS

Public Instance Methods

array_type() click to toggle source
# File lib/sequel/plugins/pg_array_associations.rb, line 80
def array_type
  cached_fetch(:array_type) do
    if (sch = associated_class.db_schema) && (s = sch[self[:key]]) && (t = s[:db_type])
      t
    else
      :integer
    end
  end
end
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 92
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 98
def can_have_associated_objects?(obj)
  obj.get_column_value(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 104
def default_key
  :"#{underscore(demodulize(self[:model].name))}_ids"
end
eager_graph_limit_strategy(_) click to toggle source

Always use the ruby eager_graph limit strategy if association is limited.

# File lib/sequel/plugins/pg_array_associations.rb, line 109
def eager_graph_limit_strategy(_)
  :ruby if self[:limit]
end
eager_limit_strategy() click to toggle source

Always use the ruby eager limit strategy

# File lib/sequel/plugins/pg_array_associations.rb, line 114
def eager_limit_strategy
  cached_fetch(:_eager_limit_strategy) do
    :ruby if self[:limit]
  end
end
filter_by_associations_limit_strategy() click to toggle source

Don’t use a filter by associations limit strategy

# File lib/sequel/plugins/pg_array_associations.rb, line 121
def filter_by_associations_limit_strategy
  nil
end
finalize_settings() click to toggle source
# File lib/sequel/plugins/pg_array_associations.rb, line 128
def finalize_settings
  FINALIZE_SETTINGS
end
handle_silent_modification_failure?() click to toggle source

Handle silent failure of add/remove methods if raise_on_save_failure is false.

# File lib/sequel/plugins/pg_array_associations.rb, line 133
def handle_silent_modification_failure?
  self[:raise_on_save_failure] == false
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 138
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 144
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 150
def remove_before_destroy?
  false
end