From 8b9733d7358f22409c86f8849faabab7f5c53881 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 22 Oct 2013 10:35:32 -0700 Subject: use the provided block to filter lists --- railties/lib/rails/paths.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 88f1dbba05..bfac24d0c3 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -98,17 +98,11 @@ module Rails protected - def filter_by - all = [] - all_paths.each do |path| - if yield(path) - paths = path.existent - paths -= path.children.map { |p| yield(p) ? [] : p.existent }.flatten - all.concat(paths) - end - end - all.uniq! - all + def filter_by(&block) + all_paths.find_all(&block).flat_map { |path| + paths = path.existent + paths - path.children.map { |p| yield(p) ? [] : p.existent }.flatten + }.uniq end end -- cgit v1.2.3