From 2fde9d774b322fc708990675671231c64c691a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 24 Jan 2010 09:00:18 +0100 Subject: Solve some pendencies. --- railties/lib/rails/paths.rb | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'railties/lib/rails/paths.rb') 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 -- cgit v1.2.3