Class Index [+]

Quicksearch

Arel::Visitors::Dot

Public Class Methods

new() click to toggle source
    # File lib/arel/visitors/dot.rb, line 17
17:       def initialize
18:         @nodes      = []
19:         @edges      = []
20:         @node_stack = []
21:         @edge_stack = []
22:         @seen       = {}
23:       end

Public Instance Methods

accept(object) click to toggle source
    # File lib/arel/visitors/dot.rb, line 25
25:       def accept object
26:         super
27:         to_dot
28:       end

Private Instance Methods

edge(name) click to toggle source
     # File lib/arel/visitors/dot.rb, line 195
195:       def edge name
196:         edge = Edge.new(name, @node_stack.last)
197:         @edge_stack.push edge
198:         @edges << edge
199:         yield
200:         @edge_stack.pop
201:       end
quote(string) click to toggle source
     # File lib/arel/visitors/dot.rb, line 213
213:       def quote string
214:         string.to_s.gsub('"', '\"')
215:       end
to_dot() click to toggle source
     # File lib/arel/visitors/dot.rb, line 217
217:       def to_dot
218:         "digraph \"ARel\" {\nnode [width=0.375,height=0.25,shape=record];\n" +
219:           @nodes.map { |node|
220:             label = "<f0>#{node.name}"
221: 
222:             node.fields.each_with_index do |field, i|
223:               label << "|<f#{i + 1}>#{quote field}"
224:             end
225: 
226:             "#{node.id} [label=\"#{label}\"];"
227:           }.join("\n") + "\n" + @edges.map { |edge|
228:             "#{edge.from.id} -> #{edge.to.id} [label=\"#{edge.name}\"];"
229:           }.join("\n") + "\n}"
230:       end
visit(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 181
181:       def visit o
182:         if node = @seen[o.object_id]
183:           @edge_stack.last.to = node
184:           return
185:         end
186: 
187:         node = Node.new(o.class.name, o.object_id)
188:         @seen[node.id] = node
189:         @nodes << node
190:         with_node node do
191:           super
192:         end
193:       end
visit_Arel_Attribute(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 120
120:       def visit_Arel_Attribute o
121:         visit_edge o, "relation"
122:         visit_edge o, "name"
123:       end
visit_Arel_Attributes_Attribute(o) click to toggle source
visit_Arel_Attributes_Boolean(o) click to toggle source
visit_Arel_Attributes_Float(o) click to toggle source
visit_Arel_Attributes_Integer(o) click to toggle source
visit_Arel_Attributes_String(o) click to toggle source
visit_Arel_Attributes_Time(o) click to toggle source
visit_Arel_Nodes_And(o) click to toggle source
visit_Arel_Nodes_Assignment(o) click to toggle source
visit_Arel_Nodes_Avg(o) click to toggle source
visit_Arel_Nodes_Between(o) click to toggle source
visit_Arel_Nodes_Count(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 53
53:       def visit_Arel_Nodes_Count o
54:         visit_edge o, "expressions"
55:         visit_edge o, "distinct"
56:       end
visit_Arel_Nodes_DeleteStatement(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 78
78:       def visit_Arel_Nodes_DeleteStatement o
79:         visit_edge o, "relation"
80:         visit_edge o, "wheres"
81:       end
visit_Arel_Nodes_DoesNotMatch(o) click to toggle source
visit_Arel_Nodes_Equality(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 131
131:       def visit_Arel_Nodes_Equality o
132:         visit_edge o, "left"
133:         visit_edge o, "right"
134:       end
visit_Arel_Nodes_GreaterThan(o) click to toggle source
visit_Arel_Nodes_GreaterThanOrEqual(o) click to toggle source
visit_Arel_Nodes_Grouping(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 31
31:       def visit_Arel_Nodes_Grouping o
32:         visit_edge o, "expr"
33:       end
visit_Arel_Nodes_In(o) click to toggle source
visit_Arel_Nodes_InnerJoin(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 71
71:       def visit_Arel_Nodes_InnerJoin o
72:         visit_edge o, "left"
73:         visit_edge o, "right"
74:         visit_edge o, "constraint"
75:       end
Also aliased as: visit_Arel_Nodes_OuterJoin
visit_Arel_Nodes_InsertStatement(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 91
91:       def visit_Arel_Nodes_InsertStatement o
92:         visit_edge o, "relation"
93:         visit_edge o, "columns"
94:         visit_edge o, "values"
95:       end
visit_Arel_Nodes_LessThan(o) click to toggle source
visit_Arel_Nodes_LessThanOrEqual(o) click to toggle source
visit_Arel_Nodes_Matches(o) click to toggle source
visit_Arel_Nodes_Max(o) click to toggle source
visit_Arel_Nodes_NotEqual(o) click to toggle source
visit_Arel_Nodes_NotIn(o) click to toggle source
visit_Arel_Nodes_Offset(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 87
87:       def visit_Arel_Nodes_Offset o
88:         visit_edge o, "value"
89:       end
visit_Arel_Nodes_On(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 58
58:       def visit_Arel_Nodes_On o
59:         visit_edge o, "expr"
60:       end
visit_Arel_Nodes_Or(o) click to toggle source
visit_Arel_Nodes_Ordering(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 35
35:       def visit_Arel_Nodes_Ordering o
36:         visit_edge o, "expr"
37:         visit_edge o, "direction"
38:       end
visit_Arel_Nodes_OuterJoin(o) click to toggle source
visit_Arel_Nodes_SelectCore(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 97
 97:       def visit_Arel_Nodes_SelectCore o
 98:         visit_edge o, "froms"
 99:         visit_edge o, "projections"
100:         visit_edge o, "wheres"
101:       end
visit_Arel_Nodes_SelectStatement(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 103
103:       def visit_Arel_Nodes_SelectStatement o
104:         visit_edge o, "cores"
105:         visit_edge o, "limit"
106:         visit_edge o, "orders"
107:         visit_edge o, "offset"
108:       end
visit_Arel_Nodes_SqlLiteral(o) click to toggle source
Alias for: visit_String
visit_Arel_Nodes_StringJoin(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 66
66:       def visit_Arel_Nodes_StringJoin o
67:         visit_edge o, "left"
68:         visit_edge o, "right"
69:       end
visit_Arel_Nodes_Sum(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 46
46:       def visit_Arel_Nodes_Sum o
47:         visit_edge o, "expressions"
48:         visit_edge o, "alias"
49:       end
visit_Arel_Nodes_TableAlias(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 40
40:       def visit_Arel_Nodes_TableAlias o
41:         visit_edge o, "name"
42:         visit_edge o, "relation"
43:         visit_edge o, "columns"
44:       end
visit_Arel_Nodes_UnqualifiedColumn(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 83
83:       def visit_Arel_Nodes_UnqualifiedColumn o
84:         visit_edge o, "attribute"
85:       end
visit_Arel_Nodes_UpdateStatement(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 110
110:       def visit_Arel_Nodes_UpdateStatement o
111:         visit_edge o, "relation"
112:         visit_edge o, "wheres"
113:         visit_edge o, "values"
114:       end
visit_Arel_Nodes_Values(o) click to toggle source
    # File lib/arel/visitors/dot.rb, line 62
62:       def visit_Arel_Nodes_Values o
63:         visit_edge o, "expressions"
64:       end
visit_Arel_SqlLiteral(o) click to toggle source
Alias for: visit_String
visit_Arel_Table(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 116
116:       def visit_Arel_Table o
117:         visit_edge o, "name"
118:       end
visit_Array(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 171
171:       def visit_Array o
172:         o.each_with_index do |x,i|
173:           edge(i) { visit x }
174:         end
175:       end
visit_BigDecimal(o) click to toggle source
Alias for: visit_String
visit_Date(o) click to toggle source
Alias for: visit_String
visit_DateTime(o) click to toggle source
Alias for: visit_String
visit_FalseClass(o) click to toggle source
Alias for: visit_String
visit_Fixnum(o) click to toggle source
Alias for: visit_String
visit_Float(o) click to toggle source
Alias for: visit_String
visit_Hash(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 165
165:       def visit_Hash o
166:         o.each_with_index do |pair, i|
167:           edge("pair_#{i}")   { visit pair }
168:         end
169:       end
visit_NilClass(o) click to toggle source
Alias for: visit_String
visit_String(o) click to toggle source
     # File lib/arel/visitors/dot.rb, line 149
149:       def visit_String o
150:         @node_stack.last.fields << o
151:       end
visit_Symbol(o) click to toggle source
Alias for: visit_String
visit_Time(o) click to toggle source
Alias for: visit_String
visit_TrueClass(o) click to toggle source
Alias for: visit_String
visit_edge(o, method) click to toggle source
     # File lib/arel/visitors/dot.rb, line 177
177:       def visit_edge o, method
178:         edge(method) { visit o.send(method) }
179:       end
with_node(node) click to toggle source
     # File lib/arel/visitors/dot.rb, line 203
203:       def with_node node
204:         if edge = @edge_stack.last
205:           edge.to = node
206:         end
207: 
208:         @node_stack.push node
209:         yield
210:         @node_stack.pop
211:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.