Class: Arel::Nodes::Window

Inherits:
Node
  • Object
show all
Includes:
Expression
Defined in:
lib/arel/nodes/window.rb

Direct Known Subclasses

NamedWindow

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from OrderPredications

#asc, #desc

Methods inherited from Node

#_caller, #and, #each, #not, #or, #to_sql

Methods included from FactoryMethods

#create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower

Constructor Details

#initializeWindow

Returns a new instance of Window.


7
8
9
# File 'lib/arel/nodes/window.rb', line 7

def initialize
  @orders = []
end

Instance Attribute Details

#framingObject

Returns the value of attribute framing


5
6
7
# File 'lib/arel/nodes/window.rb', line 5

def framing
  @framing
end

#ordersObject

Returns the value of attribute orders


5
6
7
# File 'lib/arel/nodes/window.rb', line 5

def orders
  @orders
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)

40
41
42
43
44
# File 'lib/arel/nodes/window.rb', line 40

def eql? other
  self.class == other.class &&
    self.orders == other.orders &&
    self.framing == other.framing
end

#frame(expr) ⇒ Object


19
20
21
# File 'lib/arel/nodes/window.rb', line 19

def frame(expr)
  @framing = expr
end

#hashObject


36
37
38
# File 'lib/arel/nodes/window.rb', line 36

def hash
  [@orders, @framing].hash
end

#initialize_copy(other) ⇒ Object


31
32
33
34
# File 'lib/arel/nodes/window.rb', line 31

def initialize_copy other
  super
  @orders = @orders.map { |x| x.clone }
end

#order(*expr) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/arel/nodes/window.rb', line 11

def order *expr  # FIXME: We SHOULD NOT be converting these to SqlLiteral automatically

  @orders.concat expr.map { |x|
    String === x || Symbol === x ? Nodes::SqlLiteral.new(x.to_s) : x
  }
  self
end

#range(expr = nil) ⇒ Object


27
28
29
# File 'lib/arel/nodes/window.rb', line 27

def range(expr = nil)
  frame(Range.new(expr))
end

#rows(expr = nil) ⇒ Object


23
24
25
# File 'lib/arel/nodes/window.rb', line 23

def rows(expr = nil)
  frame(Rows.new(expr))
end