Class: ActiveRecord::HierarchicalQuery::CTE::Columns
- Inherits:
-
Object
- Object
- ActiveRecord::HierarchicalQuery::CTE::Columns
- Defined in:
- lib/active_record/hierarchical_query/cte/columns.rb
Instance Method Summary collapse
-
#initialize(query) ⇒ Columns
constructor
A new instance of Columns.
-
#to_a ⇒ Object
(also: #to_ary)
returns columns to be selected from both recursive and non-recursive terms.
Constructor Details
#initialize(query) ⇒ Columns
Returns a new instance of Columns.
6 7 8 |
# File 'lib/active_record/hierarchical_query/cte/columns.rb', line 6 def initialize(query) @query = query end |
Instance Method Details
#to_a ⇒ Object Also known as: to_ary
returns columns to be selected from both recursive and non-recursive terms
11 12 13 14 |
# File 'lib/active_record/hierarchical_query/cte/columns.rb', line 11 def to_a column_names = [@query.klass.primary_key] | connect_by_columns column_names.map { |name| @query.table[name] } end |