Class: ActiveRecordExtended::QueryMethods::Window::WindowSelectBuilder

Inherits:
Object
  • Object
show all
Includes:
Utilities::Support
Defined in:
lib/active_record_extended/query_methods/window.rb

Constant Summary

Constants included from Utilities::Support

Utilities::Support::A_TO_Z_KEYS

Instance Method Summary collapse

Methods included from Utilities::Support

#double_quote, #flatten_safely, #flatten_to_sql, #from_clause_constructor, #generate_grouping, #generate_named_function, #group_when_needed, #key_generator, #literal_key, #needs_to_be_grouped?, #nested_alias_escape, #pipe_cte_with!, #to_arel_sql, #wrap_with_agg_array, #wrap_with_array

Constructor Details

#initialize(window_function, args, window_name) ⇒ WindowSelectBuilder

Returns a new instance of WindowSelectBuilder.



29
30
31
32
33
# File 'lib/active_record_extended/query_methods/window.rb', line 29

def initialize(window_function, args, window_name)
  @window_function = window_function
  @win_args        = to_sql_array(args)
  @over            = to_arel_sql(window_name)
end

Instance Method Details

#build_select(alias_name = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/active_record_extended/query_methods/window.rb', line 35

def build_select(alias_name = nil)
  window_arel = generate_named_function(@window_function, *@win_args).over(@over)

  if alias_name.nil?
    window_arel
  else
    nested_alias_escape(window_arel, alias_name)
  end
end