Class: ActiveRecord::PredicateBuilder::AssociationQueryValue

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/relation/predicate_builder/association_query_value.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(reflection, value) ⇒ AssociationQueryValue



6
7
8
9
# File 'lib/active_record/relation/predicate_builder/association_query_value.rb', line 6

def initialize(reflection, value)
  @reflection = reflection
  @value = value
end

Instance Method Details

#queriesObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/active_record/relation/predicate_builder/association_query_value.rb', line 11

def queries
  if reflection.join_foreign_key.is_a?(Array)
    id_list = ids
    id_list = id_list.pluck(primary_key) if id_list.is_a?(Relation)

    id_list.map { |ids_set| reflection.join_foreign_key.zip(ids_set).to_h }
  else
    [ reflection.join_foreign_key => ids ]
  end
end