blob: e92092d6e1b3e470e75637faf0656e4190486ac4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
module Arel
class TreeManager
def initialize engine
@engine = engine
@selects = []
# default to Select
@stmt = Nodes::SelectStatement.new
@core = @stmt.cores.last
@selects << @stmt
end
def from table
@core.froms << table
self
end
def project projection
@core.projections << projection
self
end
def where expr
@core.wheres << expr
self
end
def take limit
@stmt.limit = limit
self
end
def to_sql
viz = Visitors::ToSql.new @engine
viz.accept @stmt
end
end
end
|