Class: ActiveRecord::HierarchicalQuery::CTE::Columns

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/hierarchical_query/cte/columns.rb

Instance Method Summary collapse

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_aObject 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