lib/truck/context.rb in truck-0.8.0 vs lib/truck/context.rb in truck-0.8.1
- old
+ new
@@ -1,14 +1,15 @@
module Truck
class Context
- attr :mod, :name, :root
+ attr :autoload_paths, :mod, :name, :root
- def initialize(name, parent: nil, root:)
+ def initialize(name, parent: nil, root:, autoload_paths: ['.'])
@mod = build_mod
@name = name
@root = Pathname(root) if root
@parent = parent
+ @autoload_paths = expand_autoload_paths autoload_paths
end
class << self
def owner(const)
owner, _ = Autoloader.owner_and_ascending_nibbles const
@@ -63,9 +64,13 @@
)
end
def build_mod
Module.new
+ end
+
+ def expand_autoload_paths(paths)
+ paths.map do |path| root.join path; end
end
end
class AutoloadError < NameError