Class: ActiveRecord::PredicateBuilder::PolymorphicArrayValue

Inherits:
Object
  • Object
show all
Defined in:
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.



34
35
36
37
# File 'lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb', line 34

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.



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

def associated_table
  @associated_table
end

#valuesObject (readonly)

Returns the value of attribute values.



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

def values
  @values
end

Instance Method Details

#type_to_ids_mappingObject



39
40
41
42
# File 'lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb', line 39

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