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.
41 42 43 44 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 41 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.
39 40 41 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 39 def associated_table @associated_table end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
39 40 41 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 39 def value @value end |
Instance Method Details
#base_class ⇒ Object
57 58 59 60 61 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 57 def base_class if associated_table.polymorphic_association? @base_class ||= polymorphic_base_class_from_value end end |
#ids ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/active_record/relation/predicate_builder/association_query_handler.rb', line 46 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 |