class Rails::Paths::Root

def all_paths

def all_paths
  @all_paths.uniq!
  @all_paths
end

def autoload_once

def autoload_once
  filter_by(:autoload_once?)
end

def autoload_paths

def autoload_paths
  filter_by(:autoload?)
end

def eager_load

def eager_load
  filter_by(:eager_load?)
end

def filter_by(constraint)

def filter_by(constraint)
  all = []
  all_paths.each do |path|
    if path.send(constraint)
      paths  = path.paths
      paths -= path.children.values.map { |p| p.send(constraint) ? [] : p.paths }.flatten
      all.concat(paths)
    end
  end
  all.uniq!
  all.reject! { |p| !File.exists?(p) }
  all
end

def initialize(path)

def initialize(path)
  raise if path.is_a?(Array)
  @children = {}
  @path = path
  @root = self
  @all_paths = []
end

def load_paths

def load_paths
  filter_by(:load_path?)
end

def push(*)

def push(*)
  raise "Application root can only have one physical path"
end