Class: ServiceProvider::Provider::Automatic::Services

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/service_provider/provider/automatic.rb

Instance Method Summary collapse

Constructor Details

#initializeServices

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