Class: Sequel::Plugins::PgArrayAssociations::PgArrayToManyAssociationReflection
- Inherits:
-
Model::Associations::AssociationReflection
- Object
- Hash
- Model::Associations::AssociationReflection
- Sequel::Plugins::PgArrayAssociations::PgArrayToManyAssociationReflection
- Defined in:
- lib/sequel/plugins/pg_array_associations.rb
Overview
The AssociationReflection subclass for pg_array_to_many associations.
Constant Summary
Constants included from Inflections
Inflections::CAMELIZE_CONVERT_REGEXP, Inflections::CAMELIZE_MODULE_REGEXP, Inflections::DASH, Inflections::DEMODULIZE_CONVERT_REGEXP, Inflections::EMPTY_STRING, Inflections::SLASH, Inflections::UNDERSCORE, Inflections::UNDERSCORE_CONVERT_REGEXP1, Inflections::UNDERSCORE_CONVERT_REGEXP2, Inflections::UNDERSCORE_CONVERT_REPLACE, Inflections::UNDERSCORE_MODULE_REGEXP, Inflections::VALID_CONSTANT_NAME_REGEXP
Instance Method Summary collapse
-
#associated_object_keys ⇒ Object
An array containing the primary key for the associated model.
-
#can_have_associated_objects?(obj) ⇒ Boolean
pg_array_to_many associations can only have associated objects if the array field is not nil or empty.
-
#dataset_need_primary_key? ⇒ Boolean
pg_array_to_many associations do not need a primary key.
-
#default_key ⇒ Object
Use a default key name of *_ids, for similarity to other association types that use *_id for single keys.
-
#predicate_key ⇒ Object
A qualified version of the associated primary key.
-
#primary_key ⇒ Object
The primary key of the associated model.
-
#primary_key_method ⇒ Object
The method to call to get value of the primary key of the associated model.
Methods inherited from Model::Associations::AssociationReflection
#_add_method, #_remove_all_method, #_remove_method, #_setter_method, #add_method, #apply_dataset_changes, #associated_class, #associated_dataset, #association_method, #dataset_method, #eager_graph_lazy_dataset?, #eager_limit_strategy, #eager_loader_key, #eager_loading_predicate_key, #eager_loading_use_associated_key?, #limit_and_offset, #need_associated_primary_key?, #predicate_keys, #qualify, #qualify_assoc, #qualify_cur, #reciprocal, #reciprocal_array?, #remove_all_method, #remove_before_destroy?, #remove_method, #remove_should_check_existing?, #returns_array?, #select, #set_reciprocal_to_self?, #setter_method, #slice_range
Methods included from Inflections
clear, irregular, plural, singular, uncountable
Methods inherited from Hash
#&, #case, #hstore, #pg_json, #sql_expr, #sql_negate, #sql_or, #|, #~
Instance Method Details
#associated_object_keys ⇒ Object
An array containing the primary key for the associated model.
128 129 130 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 128 def associated_object_keys Array(primary_key) end |
#can_have_associated_objects?(obj) ⇒ Boolean
pg_array_to_many associations can only have associated objects if the array field is not nil or empty.
134 135 136 137 |
# 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 |
#dataset_need_primary_key? ⇒ Boolean
pg_array_to_many associations do not need a primary key.
140 141 142 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 140 def dataset_need_primary_key? false end |
#default_key ⇒ Object
Use a default key name of *_ids, for similarity to other association types that use *_id for single keys.
146 147 148 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 146 def default_key :"#{singularize(self[:name])}_ids" end |
#predicate_key ⇒ Object
A qualified version of the associated primary key.
151 152 153 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 151 def predicate_key cached_fetch(:predicate_key){qualify_assoc(primary_key)} end |
#primary_key ⇒ Object
The primary key of the associated model.
156 157 158 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 156 def primary_key cached_fetch(:primary_key){associated_class.primary_key} end |
#primary_key_method ⇒ Object
The method to call to get value of the primary key of the associated model.
161 162 163 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 161 def primary_key_method cached_fetch(:primary_key_method){primary_key} end |