Class: ActiveRecord::PredicateBuilder::PolymorphicArrayValue
- Inherits:
-
Object
- Object
- ActiveRecord::PredicateBuilder::PolymorphicArrayValue
- Defined in:
- lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#associated_table ⇒ Object
readonly
Returns the value of attribute associated_table.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(associated_table, values) ⇒ PolymorphicArrayValue
constructor
A new instance of PolymorphicArrayValue.
- #type_to_ids_mapping ⇒ Object
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_table ⇒ Object (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 |
#values ⇒ Object (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_mapping ⇒ Object
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 |