Permalink
Browse files

refactor block.call out of each visit method

  • Loading branch information...
1 parent 039947e commit f83affa41e67f4100f1851ed1a13fd5c912b4e1e @tenderlove tenderlove committed Nov 29, 2010
Showing with 5 additions and 14 deletions.
  1. +5 −14 lib/arel/visitors/depth_first.rb
@@ -7,9 +7,13 @@ def initialize block = nil
private
+ def visit o
+ super
+ @block.call o
+ end
+
def unary o
visit o.expr
- @block.call o
end
alias :visit_Arel_Nodes_Group :unary
alias :visit_Arel_Nodes_Grouping :unary
@@ -22,7 +26,6 @@ def unary o
def function o
visit o.expressions
visit o.alias
- @block.call o
end
alias :visit_Arel_Nodes_Avg :function
alias :visit_Arel_Nodes_Exists :function
@@ -34,22 +37,19 @@ def visit_Arel_Nodes_Count o
visit o.expressions
visit o.alias
visit o.distinct
- @block.call o
end
def join o
visit o.left
visit o.right
visit o.constraint
- @block.call o
end
alias :visit_Arel_Nodes_InnerJoin :join
alias :visit_Arel_Nodes_OuterJoin :join
def binary o
visit o.left
visit o.right
- @block.call o
end
alias :visit_Arel_Nodes_And :binary
alias :visit_Arel_Nodes_As :binary
@@ -75,7 +75,6 @@ def binary o
def visit_Arel_Attribute o
visit o.relation
visit o.name
- @block.call o
end
alias :visit_Arel_Attributes_Integer :visit_Arel_Attribute
alias :visit_Arel_Attributes_Float :visit_Arel_Attribute
@@ -87,11 +86,9 @@ def visit_Arel_Attribute o
def visit_Arel_Table o
visit o.name
- @block.call o
end
def terminal o
- @block.call o
end
alias :visit_ActiveSupport_Multibyte_Chars :terminal
alias :visit_ActiveSupport_StringInquirer :terminal
@@ -116,7 +113,6 @@ def visit_Arel_Nodes_InsertStatement o
visit o.relation
visit o.columns
visit o.values
- @block.call o
end
def visit_Arel_Nodes_SelectCore o
@@ -125,7 +121,6 @@ def visit_Arel_Nodes_SelectCore o
visit o.wheres
visit o.groups
visit o.having
- @block.call o
end
def visit_Arel_Nodes_SelectStatement o
@@ -134,7 +129,6 @@ def visit_Arel_Nodes_SelectStatement o
visit o.limit
visit o.lock
visit o.offset
- @block.call o
end
def visit_Arel_Nodes_UpdateStatement o
@@ -143,17 +137,14 @@ def visit_Arel_Nodes_UpdateStatement o
visit o.wheres
visit o.orders
visit o.limit
- @block.call o
end
def visit_Array o
o.each { |i| visit i }
- @block.call o
end
def visit_Hash o
o.each { |k,v| visit(k); visit(v) }
- @block.call o
end
end
end

0 comments on commit f83affa

Please sign in to comment.