Class: ActiveRecord::PredicateBuilder::AssociationQueryValue
- Inherits:
-
Object
- Object
- ActiveRecord::PredicateBuilder::AssociationQueryValue
- Defined in:
- lib/active_record/relation/predicate_builder/association_query_handler.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#associated_table ⇒ Object
readonly
Returns the value of attribute associated_table.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #base_class ⇒ Object
- #ids ⇒ Object
-
#initialize(associated_table, value) ⇒ AssociationQueryValue
constructor
A new instance of AssociationQueryValue.
Constructor Details
#initialize(associated_table, value) ⇒ AssociationQueryValue
Returns a new instance of AssociationQueryValue.
38 39 40 41 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 38 def initialize(associated_table, value) @associated_table = associated_table @value = value end |
Instance Attribute Details
#associated_table ⇒ Object (readonly)
Returns the value of attribute associated_table.
36 37 38 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 36 def associated_table @associated_table end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
36 37 38 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 36 def value @value end |
Instance Method Details
#base_class ⇒ Object
54 55 56 57 58 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 54 def base_class if associated_table.polymorphic_association? @base_class ||= polymorphic_base_class_from_value end end |
#ids ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 43 def ids case value when Relation value.select(primary_key) when Array value.map { |v| convert_to_id(v) } else convert_to_id(value) end end |