Class: ActiveRecord::HierarchicalQuery::Adapters::Abstract Private
- Inherits:
-
Object
- Object
- ActiveRecord::HierarchicalQuery::Adapters::Abstract
- Defined in:
- lib/active_record/hierarchical_query/adapters/abstract.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Attribute Summary collapse
- #query ⇒ Object readonly private
- #table ⇒ Object readonly private
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(query) ⇒ Abstract
constructor
private
A new instance of Abstract.
- #visit(kind, object) ⇒ Object private
Constructor Details
#initialize(query) ⇒ Abstract
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Abstract.
24 25 26 27 |
# File 'lib/active_record/hierarchical_query/adapters/abstract.rb', line 24 def initialize(query) @query = query @table = klass.arel_table end |
Instance Attribute Details
#query ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/active_record/hierarchical_query/adapters/abstract.rb', line 10 def query @query end |
#table ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/active_record/hierarchical_query/adapters/abstract.rb', line 10 def table @table end |
Class Method Details
.visitors(*visitors_classes) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 |
# File 'lib/active_record/hierarchical_query/adapters/abstract.rb', line 16 def visitors(*visitors_classes) define_method :visitors do @visitors ||= visitors_classes.map { |klass| klass.new(@query) } end end |
Instance Method Details
#visit(kind, object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 37 |
# File 'lib/active_record/hierarchical_query/adapters/abstract.rb', line 31 def visit(kind, object) method_name = "visit_#{kind}" visitors.reduce(object) do |*, visitor| visitor.send(method_name, object) if visitor.respond_to?(method_name) end end |