Module: CoreExtensions::Arel::SelectManager

Defined in:
lib/core_extensions/arel/select_manager.rb

Instance Method Summary collapse

Instance Method Details

#final!Object



5
6
7
8
# File 'lib/core_extensions/arel/select_manager.rb', line 5

def final!
  @ctx.final = true
  self
end

#limit_by(*exprs) ⇒ Object



33
34
35
36
# File 'lib/core_extensions/arel/select_manager.rb', line 33

def limit_by(*exprs)
  @ast.limit_by = ::Arel::Nodes::LimitBy.new(*exprs)
  self
end

#settings(values) ⇒ Object

Parameters:

  • values (Hash)


11
12
13
14
# File 'lib/core_extensions/arel/select_manager.rb', line 11

def settings(values)
  @ast.settings = ::Arel::Nodes::Settings.new(values)
  self
end

#using(*exprs) ⇒ Object



28
29
30
31
# File 'lib/core_extensions/arel/select_manager.rb', line 28

def using(*exprs)
  @ctx.source.right.last.right = ::Arel::Nodes::Using.new(::Arel.sql(exprs.join(',')))
  self
end

#windows(windows) ⇒ Object

Parameters:

  • windows (Array)


17
18
19
20
21
22
23
24
25
26
# File 'lib/core_extensions/arel/select_manager.rb', line 17

def windows(windows)
  @ctx.windows = windows.map do |name, opts|
    # https://github.com/rails/rails/blob/main/activerecord/test/cases/arel/select_manager_test.rb#L790
    window = ::Arel::Nodes::NamedWindow.new(name)
    opts.each do |key, value|
      window.send(key, value)
    end
    window
  end
end