aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/nodes
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-11-29 14:11:28 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-29 14:11:28 -0800
commitc86c37e5f32ca76fa7aa77e62018e368dbb37a54 (patch)
treed3e5f7abdd92b4a6349de2ce2d9ebde3723cb234 /lib/arel/nodes
parentf092ae544f58255508242a5308c456d9b8a13b0c (diff)
downloadrails-c86c37e5f32ca76fa7aa77e62018e368dbb37a54.tar.gz
rails-c86c37e5f32ca76fa7aa77e62018e368dbb37a54.tar.bz2
rails-c86c37e5f32ca76fa7aa77e62018e368dbb37a54.zip
mostly implemented depth-first traversal
Diffstat (limited to 'lib/arel/nodes')
-rw-r--r--lib/arel/nodes/node.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/arel/nodes/node.rb b/lib/arel/nodes/node.rb
index 841b954db9..90c63f0be9 100644
--- a/lib/arel/nodes/node.rb
+++ b/lib/arel/nodes/node.rb
@@ -3,6 +3,8 @@ module Arel
###
# Abstract base class for all AST nodes
class Node
+ include Enumerable
+
###
# Factory method to create a Nodes::Not node that has the recipient of
# the caller as a child.
@@ -32,6 +34,11 @@ module Arel
viz = Visitors.for engine
viz.accept self
end
+
+ # Iterate through AST, nodes will be yielded depth-first
+ def each &block
+ Visitors::DepthFirst.new(block).accept self
+ end
end
end
end