class Pico::Application
Attributes
autoload_paths[RW]
Public Class Methods
new(name, root: nil, **params, &config_block)
click to toggle source
Calls superclass method
# File lib/pico/application.rb, line 5 def initialize(name, root: nil, **params, &config_block) super name, root: root, **params @autoload_paths = [] @injector = build_injector configure(config_block) if block_given? end
Private Class Methods
default_root()
click to toggle source
# File lib/pico/application.rb, line 51 def default_root caller_locations.reduce do |previous_location, location| if previous_location.label == "boot!" && File.basename(location.path) != "pico.rb" return Pathname(location.absolute_path).dirname end location end end
Public Instance Methods
boot!()
click to toggle source
Calls superclass method
# File lib/pico/application.rb, line 16 def boot! self.root ||= self.class.default_root super end
build_const_resolver(expanded_const)
click to toggle source
Calls superclass method
# File lib/pico/application.rb, line 21 def build_const_resolver(expanded_const) resolver = super resolver.autoload_paths = autoload_paths resolver end
configure(config_block)
click to toggle source
# File lib/pico/application.rb, line 12 def configure(config_block) ConfigurationContext.evaluate(config_block, application: self) end
possible_implicit_namespace?(path)
click to toggle source
# File lib/pico/application.rb, line 27 def possible_implicit_namespace?(path) autoload_paths.any? do |autoload_path| root.join(autoload_path, path).directory? end end
root=(dir)
click to toggle source
# File lib/pico/application.rb, line 33 def root=(dir) raise ArgumentError, "Cannot alter root after booting" if booted? @root = Pathname(dir) end
Private Instance Methods
build_injector()
click to toggle source
# File lib/pico/application.rb, line 40 def build_injector injector = Ruse.create_injector injector.pico_context = self injector end
build_mod()
click to toggle source
# File lib/pico/application.rb, line 46 def build_mod ApplicationModule.new self end