diff options
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 |