class Jerry
Inversion of Control container.
This class is in charge of bootstrapping your application. This is done by defining {Jerry::Config configs}.
@example Basic usage
class FooConfig < Jerry::Config # ... end class BarConfig < Jerry::Config # ... end jerry = Jerry.new FooConfig.new, BarConfig.new jerry[SomeClass] #=> #<Someclass:...>
Constants
- VERSION
Public Class Methods
new(*configs)
click to toggle source
@param configs [Array<Jerry::Config>] configurations describing how to wire
your application
# File lib/jerry.rb, line 24 def initialize(*configs) configs.each { |conf| conf.jerry = self } @configs = configs end
Public Instance Methods
[](key)
click to toggle source
@param key what to provide @return an insance of the sepcified key provided by one of the configs @raise [Jerry::InstantiationError] if can't instanciate key
# File lib/jerry.rb, line 33 def [](key) config = @configs.find { |conf| conf.knows? key } unless config raise Jerry::InstantiationError, "Can't find #{key} in any config" end config[key] end