Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use the provided block to filter lists

  • Loading branch information...
commit 8b9733d7358f22409c86f8849faabab7f5c53881 1 parent 2dc8894
Aaron Patterson tenderlove authored
Showing with 5 additions and 11 deletions.
  1. +5 −11 railties/lib/rails/paths.rb
16 railties/lib/rails/paths.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.