Class: Bmg::Sql::Processor::LimitOffset

Inherits:
Bmg::Sql::Processor show all
Defined in:
lib/bmg/sql/processor/limit_offset.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(limit, offset, builder) ⇒ LimitOffset

Returns a new instance of LimitOffset.



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

def initialize(limit, offset, builder)
  super(builder)
  @limit = limit
  @offset = offset
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



11
12
13
# File 'lib/bmg/sql/processor/limit_offset.rb', line 11

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



11
12
13
# File 'lib/bmg/sql/processor/limit_offset.rb', line 11

def offset
  @offset
end

Instance Method Details

#on_select_exp(sexpr) ⇒ Object



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

def on_select_exp(sexpr)
  sexpr = builder.from_self(sexpr) if must_from_self?(sexpr)

  limit_clause = builder.limit_clause(limit)
  offset_clause = builder.offset_clause(offset)
  sexpr.with_push(limit_clause, offset_clause)
end

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



13
14
15
# File 'lib/bmg/sql/processor/limit_offset.rb', line 13

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