Class | Sequel::Plugins::PgArrayAssociations::PgArrayToManyAssociationReflection |
In: |
lib/sequel/plugins/pg_array_associations.rb
|
Parent: | Sequel::Model::Associations::AssociationReflection |
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 128: def associated_object_keys 129: Array(primary_key) 130: 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 134: def can_have_associated_objects?(obj) 135: v = obj.send(self[:key]) 136: v && !v.empty? 137: end
pg_array_to_many associations do not need a primary key.
# File lib/sequel/plugins/pg_array_associations.rb, line 140 140: def dataset_need_primary_key? 141: false 142: 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 146: def default_key 147: 148: "#{singularize(self[:name])}_ids" 149: end
A qualified version of the associated primary key.
# File lib/sequel/plugins/pg_array_associations.rb, line 151 151: def predicate_key 152: cached_fetch(:predicate_key){qualify_assoc(primary_key)} 153: end
The primary key of the associated model.
# File lib/sequel/plugins/pg_array_associations.rb, line 156 156: def primary_key 157: cached_fetch(:primary_key){associated_class.primary_key} 158: end