Class: ActiveRecord::PredicateBuilder::PolymorphicArrayValue
- Defined in:
- activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(associated_table, values) ⇒ PolymorphicArrayValue
constructor
A new instance of PolymorphicArrayValue.
- #queries ⇒ Object
Constructor Details
#initialize(associated_table, values) ⇒ PolymorphicArrayValue
Returns a new instance of PolymorphicArrayValue.
6 7 8 9 |
# File 'activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb', line 6 def initialize(associated_table, values) @associated_table = associated_table @values = values end |
Instance Method Details
#queries ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb', line 11 def queries return [ associated_table.join_foreign_key => values ] if values.empty? type_to_ids_mapping.map do |type, ids| query = {} query[associated_table.join_foreign_type] = type if type query[associated_table.join_foreign_key] = ids query end end |