Class: ActiveRecord::HierarchicalQuery::CTE::Query
- Inherits:
-
Object
- Object
- ActiveRecord::HierarchicalQuery::CTE::Query
- Defined in:
- lib/active_record/hierarchical_query/cte/query.rb
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#cycle_detector ⇒ Object
readonly
Returns the value of attribute cycle_detector.
-
#orderings ⇒ Object
readonly
Returns the value of attribute orderings.
Instance Method Summary collapse
- #arel ⇒ Arel::SelectManager
- #build_join(relation, subquery_alias) ⇒ Object
-
#initialize(builder) ⇒ Query
constructor
A new instance of Query.
- #join_conditions ⇒ Object
- #order_clause ⇒ Object
- #recursive_table ⇒ Arel::Table
Constructor Details
#initialize(builder) ⇒ Query
Returns a new instance of Query.
21 22 23 24 25 26 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 21 def initialize(builder) @builder = builder @orderings = Orderings.new(builder) @columns = Columns.new(self) @cycle_detector = CycleDetector.new(self) end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
13 14 15 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 13 def builder @builder end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
13 14 15 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 13 def columns @columns end |
#cycle_detector ⇒ Object (readonly)
Returns the value of attribute cycle_detector.
13 14 15 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 13 def cycle_detector @cycle_detector end |
#orderings ⇒ Object (readonly)
Returns the value of attribute orderings.
13 14 15 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 13 def orderings @orderings end |
Instance Method Details
#arel ⇒ Arel::SelectManager
33 34 35 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 33 def arel apply_ordering { build_arel } end |
#build_join(relation, subquery_alias) ⇒ Object
28 29 30 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 28 def build_join(relation, subquery_alias) JoinBuilder.new(self, relation, subquery_alias).build end |
#join_conditions ⇒ Object
42 43 44 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 42 def join_conditions builder.connect_by_value[recursive_table, table] end |
#order_clause ⇒ Object
46 47 48 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 46 def order_clause recursive_table[orderings.column_name].asc end |
#recursive_table ⇒ Arel::Table
38 39 40 |
# File 'lib/active_record/hierarchical_query/cte/query.rb', line 38 def recursive_table @recursive_table ||= Arel::Table.new("#{table.name}__recursive") end |