# File lib/sequel/plugins/pg_array_associations.rb, line 156 def primary_key cached_fetch(:primary_key){associated_class.primary_key} end
The AssociationReflection subclass for pg_array_to_many associations.
An array containing the primary key for the associated model.
# File lib/sequel/plugins/pg_array_associations.rb, line 128 def associated_object_keys Array(primary_key) end
pg_array_to_many associations can only have associated objects if the array field is not nil or empty.
# File lib/sequel/plugins/pg_array_associations.rb, line 134 def can_have_associated_objects?(obj) v = obj.send(self[:key]) v && !v.empty? end
pg_array_to_many associations do not need a primary key.
# File lib/sequel/plugins/pg_array_associations.rb, line 140 def dataset_need_primary_key? false end
Use a default key name of *_ids, for similarity to other association types that use *_id for single keys.
# File lib/sequel/plugins/pg_array_associations.rb, line 146 def default_key :"#{singularize(self[:name])}_ids" end
A qualified version of the associated primary key.
# File lib/sequel/plugins/pg_array_associations.rb, line 151 def predicate_key cached_fetch(:predicate_key){qualify_assoc(primary_key)} end
The primary key of the associated model.
# File lib/sequel/plugins/pg_array_associations.rb, line 156 def primary_key cached_fetch(:primary_key){associated_class.primary_key} end
The method to call to get value of the primary key of the associated model.
# File lib/sequel/plugins/pg_array_associations.rb, line 161 def primary_key_method cached_fetch(:primary_key_method){primary_key} end
Only consider an association as a reciprocal if it has matching keys and primary keys.
# File lib/sequel/plugins/pg_array_associations.rb, line 169 def reciprocal_association?(assoc_reflect) super && self[:key] == assoc_reflect[:key] && primary_key == assoc_reflect.primary_key end
# File lib/sequel/plugins/pg_array_associations.rb, line 173 def reciprocal_type :many_to_pg_array end