diff options
Diffstat (limited to 'railties/lib/rails/paths.rb')
-rw-r--r-- | railties/lib/rails/paths.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 3899b744b0..b3d105d8c7 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -19,14 +19,14 @@ module Rails class Root include PathParent - attr_reader :path + attr_accessor :path + def initialize(path) - raise unless path.is_a?(String) + raise if path.is_a?(Array) @children = {} - # TODO: Move logic from set_root_path initializer - @path = File.expand_path(path) + @path = path @root = self @all_paths = [] end @@ -64,7 +64,7 @@ module Rails end class Path - include PathParent + include PathParent, Enumerable attr_reader :path attr_accessor :glob @@ -83,6 +83,10 @@ module Rails @root.all_paths << self end + def each + to_a.each { |p| yield p } + end + def push(path) @paths.push path end @@ -123,8 +127,10 @@ module Rails end def paths + raise "You need to set a path root" unless @root.path + @paths.map do |path| - path.index('/') == 0 ? path : File.join(@root.path, path) + path.index('/') == 0 ? path : File.expand_path(File.join(@root.path, path)) end end |