Class: Bmg::Sql::Processor::OrderBy

Inherits:
Bmg::Sql::Processor show all
Defined in:
lib/bmg/sql/processor/order_by.rb

Constant Summary

Constants inherited from Bmg::Sql::Processor

UnexpectedError

Instance Attribute Summary collapse

Attributes inherited from Bmg::Sql::Processor

#builder

Instance Method Summary collapse

Methods inherited from Bmg::Sql::Processor

#on_with_exp

Constructor Details

#initialize(ordering, builder) ⇒ OrderBy

Returns a new instance of OrderBy.



6
7
8
9
# File 'lib/bmg/sql/processor/order_by.rb', line 6

def initialize(ordering, builder)
  super(builder)
  @ordering = ordering
end

Instance Attribute Details

#orderingObject (readonly)

Returns the value of attribute ordering.



10
11
12
# File 'lib/bmg/sql/processor/order_by.rb', line 10

def ordering
  @ordering
end

Instance Method Details

#on_select_exp(sexpr) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/bmg/sql/processor/order_by.rb', line 19

def on_select_exp(sexpr)
  if sexpr.order_by? || sexpr.group_by?
    sexpr = builder.from_self(sexpr)
    call(sexpr)
  else
    needed = builder.order_by_clause(ordering, &sexpr.desaliaser)
    sexpr.dup.push(needed)
  end
end

#on_set_operator(sexpr) ⇒ Object Also known as: on_union, on_except, on_intersect



12
13
14
# File 'lib/bmg/sql/processor/order_by.rb', line 12

def on_set_operator(sexpr)
  call(builder.from_self(sexpr))
end