aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/paths.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-22 10:35:32 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-22 10:42:47 -0700
commit8b9733d7358f22409c86f8849faabab7f5c53881 (patch)
tree5b267dee2dc34657d68fbdeae980ec6cd6c4176a /railties/lib/rails/paths.rb
parent2dc889401c6e922c04b4783d9f0593be98e1499a (diff)
downloadrails-8b9733d7358f22409c86f8849faabab7f5c53881.tar.gz
rails-8b9733d7358f22409c86f8849faabab7f5c53881.tar.bz2
rails-8b9733d7358f22409c86f8849faabab7f5c53881.zip
use the provided block to filter lists
Diffstat (limited to 'railties/lib/rails/paths.rb')
-rw-r--r--railties/lib/rails/paths.rb16
1 files changed, 5 insertions, 11 deletions
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