Class: Sequel::Plugins::PgArrayAssociations::ManyToPgArrayAssociationReflection
- Inherits:
-
Model::Associations::AssociationReflection
- Object
- Hash
- Model::Associations::AssociationReflection
- Sequel::Plugins::PgArrayAssociations::ManyToPgArrayAssociationReflection
- Defined in:
- lib/sequel/plugins/pg_array_associations.rb
Overview
The AssociationReflection subclass for many_to_pg_array 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
The array column in the associated model containing foreign keys to the current model.
-
#can_have_associated_objects?(obj) ⇒ Boolean
many_to_pg_array associations can have associated objects as long as they have a primary key.
-
#default_key ⇒ Object
Assume that the key in the associated table uses a version of the current model’s name suffixed with _ids.
-
#eager_graph_limit_strategy(_) ⇒ Object
Always use the ruby eager_graph limit strategy if association is limited.
-
#eager_limit_strategy ⇒ Object
Always use the ruby eager limit strategy.
-
#handle_silent_modification_failure? ⇒ Boolean
Handle silent failure of add/remove methods if raise_on_save_failure is false.
-
#predicate_key ⇒ Object
The hash key to use for the eager loading predicate (left side of IN (1, 2, 3)).
-
#primary_key ⇒ Object
The column in the current table that the keys in the array column in the associated table reference.
-
#remove_before_destroy? ⇒ Boolean
Destroying the associated object automatically removes the association, since the association is stored in the associated object.
Methods inherited from Model::Associations::AssociationReflection
#_add_method, #_remove_all_method, #_remove_method, #_setter_method, #add_method, #apply_dataset_changes, #apply_distinct_on_eager_limit_strategy, #apply_eager_graph_limit_strategy, #apply_eager_limit_strategy, #apply_ruby_eager_limit_strategy, #apply_window_function_eager_limit_strategy, #assign_singular?, #associated_class, #associated_dataset, #association_method, #cloneable?, #dataset_method, #dataset_need_primary_key?, #delete_row_number_column, #eager_graph_lazy_dataset?, #eager_loader_key, #eager_loading_predicate_key, #eager_loading_use_associated_key?, #filter_by_associations_add_conditions?, #filter_by_associations_conditions_expression, #initialize_association_cache, #limit_and_offset, #need_associated_primary_key?, #predicate_keys, #qualify, #qualify_assoc, #qualify_cur, #reciprocal, #reciprocal_array?, #remove_all_method, #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
The array column in the associated model containing foreign keys to the current model.
82 83 84 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 82 def associated_object_keys [self[:key]] end |
#can_have_associated_objects?(obj) ⇒ Boolean
many_to_pg_array associations can have associated objects as long as they have a primary key.
88 89 90 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 88 def can_have_associated_objects?(obj) obj.send(self[:primary_key]) end |
#default_key ⇒ Object
Assume that the key in the associated table uses a version of the current model’s name suffixed with _ids.
94 95 96 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 94 def default_key :"#{underscore(demodulize(self[:model].name))}_ids" end |
#eager_graph_limit_strategy(_) ⇒ Object
Always use the ruby eager_graph limit strategy if association is limited.
99 100 101 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 99 def eager_graph_limit_strategy(_) :ruby if self[:limit] end |
#eager_limit_strategy ⇒ Object
Always use the ruby eager limit strategy
104 105 106 107 108 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 104 def eager_limit_strategy cached_fetch(:_eager_limit_strategy) do :ruby if self[:limit] end end |
#handle_silent_modification_failure? ⇒ Boolean
Handle silent failure of add/remove methods if raise_on_save_failure is false.
111 112 113 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 111 def handle_silent_modification_failure? self[:raise_on_save_failure] == false end |
#predicate_key ⇒ Object
The hash key to use for the eager loading predicate (left side of IN (1, 2, 3))
116 117 118 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 116 def predicate_key cached_fetch(:predicate_key){qualify_assoc(self[:key_column])} end |
#primary_key ⇒ Object
The column in the current table that the keys in the array column in the associated table reference.
122 123 124 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 122 def primary_key self[:primary_key] end |
#remove_before_destroy? ⇒ Boolean
Destroying the associated object automatically removes the association, since the association is stored in the associated object.
128 129 130 |
# File 'lib/sequel/plugins/pg_array_associations.rb', line 128 def remove_before_destroy? false end |