diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-24 09:00:18 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-24 09:32:54 +0100 |
commit | 2fde9d774b322fc708990675671231c64c691a33 (patch) | |
tree | f38713fcab2e54cf4ad34652042df34864608440 /railties/lib/rails/paths.rb | |
parent | d3c40242a58a8863cd216f6639f93df5fdb0c075 (diff) | |
download | rails-2fde9d774b322fc708990675671231c64c691a33.tar.gz rails-2fde9d774b322fc708990675671231c64c691a33.tar.bz2 rails-2fde9d774b322fc708990675671231c64c691a33.zip |
Solve some pendencies.
Diffstat (limited to 'railties/lib/rails/paths.rb')
-rw-r--r-- | railties/lib/rails/paths.rb | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 88c0c1c68c..55874813da 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -31,22 +31,21 @@ module Rails @all_paths = [] end - def load_once - all_paths.map { |path| path.paths if path.load_once? }.compact.flatten.uniq + def all_paths + @all_paths.uniq! + @all_paths end - def eager_load - all_paths.map { |path| path.paths if path.eager_load? }.compact.flatten.uniq + def load_once + filter { |path| path.paths if path.load_once? } end - # TODO Discover why do we need to call uniq! here - def all_paths - @all_paths.uniq! - @all_paths + def eager_load + filter { |path| path.paths if path.eager_load? } end def load_paths - all_paths.map { |path| path.paths if path.load_path? }.compact.flatten.uniq + filter { |path| path.paths if path.load_path? } end def push(*) @@ -56,6 +55,12 @@ module Rails alias unshift push alias << push alias concat push + + protected + + def filter(&block) + all_paths.map(&block).compact.flatten.uniq.select { |p| File.exists?(p) } + end end class Path |