Class: ActiveRecord::PredicateBuilder::PolymorphicArrayValue

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(associated_table, values) ⇒ PolymorphicArrayValue

Returns a new instance of PolymorphicArrayValue.


32
33
34
35
# File 'activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb', line 32

def initialize(associated_table, values)
  @associated_table = associated_table
  @values = values
end

Instance Attribute Details

#associated_tableObject (readonly)

Returns the value of attribute associated_table


30
31
32
# File 'activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb', line 30

def associated_table
  @associated_table
end

#valuesObject (readonly)

Returns the value of attribute values


30
31
32
# File 'activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb', line 30

def values
  @values
end

Instance Method Details

#type_to_ids_mappingObject


37
38
39
40
# File 'activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb', line 37

def type_to_ids_mapping
  default_hash = Hash.new { |hsh, key| hsh[key] = [] }
  values.each_with_object(default_hash) { |value, hash| hash[base_class(value).name] << convert_to_id(value) }
end