From 82d81bbfcb4d0d895e9ba059f33a3495879bc660 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 10 Oct 2013 10:09:15 -0700 Subject: simplify each method. Stop writing terrible code Aaron. This is Ruby, not Scheme --- .../active_record/associations/join_dependency/join_part.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record/associations/join_dependency/join_part.rb') diff --git a/activerecord/lib/active_record/associations/join_dependency/join_part.rb b/activerecord/lib/active_record/associations/join_dependency/join_part.rb index d536eaf613..7175dff5ac 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_part.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_part.rb @@ -50,15 +50,9 @@ module ActiveRecord parents end - def each + def each(&block) yield self - iter = lambda { |list| - list.each { |item| - yield item - iter.call item.children - } - } - iter.call children + children.each { |child| child.each(&block) } end def aliased_table -- cgit v1.2.3