Permalink
Browse files

use the provided block to filter lists

  • Loading branch information...
1 parent 2dc8894 commit 8b9733d7358f22409c86f8849faabab7f5c53881 @tenderlove tenderlove committed Oct 22, 2013
Showing with 5 additions and 11 deletions.
  1. +5 −11 railties/lib/rails/paths.rb
@@ -98,17 +98,11 @@ def load_paths
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

0 comments on commit 8b9733d

Please sign in to comment.