Class: ServiceProvider::Provider::Automatic::Services
- Inherits:
-
Object
- Object
- ServiceProvider::Provider::Automatic::Services
- Includes:
- Singleton
- Defined in:
- lib/service_provider/provider/automatic.rb
Instance Method Summary collapse
- #get(service_name) ⇒ Object
-
#initialize ⇒ Services
constructor
A new instance of Services.
- #put(service_name, service_class) ⇒ Object
Constructor Details
#initialize ⇒ Services
Returns a new instance of Services.
27 28 29 30 |
# File 'lib/service_provider/provider/automatic.rb', line 27 def initialize @services = {} @service_constructors = {} end |
Instance Method Details
#get(service_name) ⇒ Object
36 37 38 |
# File 'lib/service_provider/provider/automatic.rb', line 36 def get(service_name) @services[service_name] ||= @service_constructors[service_name].new end |
#put(service_name, service_class) ⇒ Object
32 33 34 |
# File 'lib/service_provider/provider/automatic.rb', line 32 def put(service_name, service_class) @service_constructors[service_name] = service_class end |