diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-22 10:35:32 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-22 10:42:47 -0700 |
commit | 8b9733d7358f22409c86f8849faabab7f5c53881 (patch) | |
tree | 5b267dee2dc34657d68fbdeae980ec6cd6c4176a | |
parent | 2dc889401c6e922c04b4783d9f0593be98e1499a (diff) | |
download | rails-8b9733d7358f22409c86f8849faabab7f5c53881.tar.gz rails-8b9733d7358f22409c86f8849faabab7f5c53881.tar.bz2 rails-8b9733d7358f22409c86f8849faabab7f5c53881.zip |
use the provided block to filter lists
-rw-r--r-- | railties/lib/rails/paths.rb | 16 |
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 |