Sha256: 71d376b73990a09d4204d42df382a399e2133060d92534bc60a9b352b8fa621f

Contents?: true

Size: 784 Bytes

Versions: 16

Compression:

Stored size: 784 Bytes

Contents

module Hoth
  
  # The ServiceRegistry knows all registered services. You can register new
  # services and locate existing services.
  
  class ServiceRegistry
    include Singleton
    
    # add a service to the registry
    def self.add_service(service)
      instance.add_service(service)
    end
    # alias_method :register_service, :add_service
    
    # find a service with a given name
    def self.locate_service(service_name)
      instance.locate_service(service_name)
    end
    
    def add_service(service) # :nodoc:
      @registry[service.name.to_sym] = service
    end
    
    def locate_service(service_name) # :nodoc:
      @registry[service_name.to_sym]
    end
    
    private
      
      def initialize # :nodoc:
        @registry = {}
      end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
hoth-0.4.2 lib/hoth/service_registry.rb
hoth-0.4.1 lib/hoth/service_registry.rb
hoth-0.4.0 lib/hoth/service_registry.rb
hoth-0.3.4 lib/hoth/service_registry.rb
hoth-0.3.3 lib/hoth/service_registry.rb
hoth-0.3.2.beta4 lib/hoth/service_registry.rb
hoth-0.3.2.beta3 lib/hoth/service_registry.rb
hoth-0.3.2.beta2 lib/hoth/service_registry.rb
hoth-0.3.2.beta1 lib/hoth/service_registry.rb
hoth-0.3.1 lib/hoth/service_registry.rb
sk-hoth-0.3.5 lib/hoth/service_registry.rb
sk-hoth-0.3.4 lib/hoth/service_registry.rb
sk-hoth-0.3.2 lib/hoth/service_registry.rb
sk-hoth-0.3.1 lib/hoth/service_registry.rb
sk-hoth-0.3.0 lib/hoth/service_registry.rb
hoth-0.3.0 lib/hoth/service_registry.rb