diff options
Diffstat (limited to 'lib/arel/nodes/node.rb')
-rw-r--r-- | lib/arel/nodes/node.rb | 7 |
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 |