diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-29 15:31:28 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-29 15:31:28 -0800 |
commit | f68b7c4e7e25415c41308a5c37f1096a524b6d09 (patch) | |
tree | fb713329b508de307c9708f440b780bf3ae48a12 /lib | |
parent | ae4c814f537416345332b07bcaeaa199b75aa706 (diff) | |
download | rails-f68b7c4e7e25415c41308a5c37f1096a524b6d09.tar.gz rails-f68b7c4e7e25415c41308a5c37f1096a524b6d09.tar.bz2 rails-f68b7c4e7e25415c41308a5c37f1096a524b6d09.zip |
base class works with visitor
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/nodes/node.rb | 2 | ||||
-rw-r--r-- | lib/arel/visitors/depth_first.rb | 1 |
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/arel/nodes/node.rb b/lib/arel/nodes/node.rb index 90c63f0be9..634e580a8f 100644 --- a/lib/arel/nodes/node.rb +++ b/lib/arel/nodes/node.rb @@ -37,6 +37,8 @@ module Arel # Iterate through AST, nodes will be yielded depth-first def each &block + return enum_for(:each) unless block_given? + Visitors::DepthFirst.new(block).accept self end end diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb index 46171dc5bd..00f18727f0 100644 --- a/lib/arel/visitors/depth_first.rb +++ b/lib/arel/visitors/depth_first.rb @@ -93,6 +93,7 @@ module Arel alias :visit_ActiveSupport_Multibyte_Chars :terminal alias :visit_ActiveSupport_StringInquirer :terminal alias :visit_Arel_Nodes_Lock :terminal + alias :visit_Arel_Nodes_Node :terminal alias :visit_Arel_Nodes_SqlLiteral :terminal alias :visit_Arel_SqlLiteral :terminal alias :visit_BigDecimal :terminal |