Class: Garcon::ServiceLocator
- Inherits:
-
Object
- Object
- Garcon::ServiceLocator
- Defined in:
- lib/garcon/service_locator.rb
Instance Method Summary collapse
- #[](service_name) ⇒ Object
-
#initialize ⇒ ServiceLocator
constructor
A new instance of ServiceLocator.
- #register(service_name, &handler) ⇒ Object
Constructor Details
#initialize ⇒ ServiceLocator
Returns a new instance of ServiceLocator.
4 5 6 7 |
# File 'lib/garcon/service_locator.rb', line 4 def initialize super @services = {} end |
Instance Method Details
#[](service_name) ⇒ Object
9 10 11 |
# File 'lib/garcon/service_locator.rb', line 9 def [] service_name @services[service_name.to_s].call end |
#register(service_name, &handler) ⇒ Object
13 14 15 |
# File 'lib/garcon/service_locator.rb', line 13 def register service_name, &handler @services[service_name.to_s] = handler end |