class ServiceList
  private_class_method :new
  @@services = nil
  
  def self.get(name)
    @@services = YAML.load_file(RAILS_ROOT+"/config/services.yml") unless @@services   
    require 'service_adaptors/'+@@services[name]["type"].underscore   
    return Kernel.const_get(@@services[name]["type"]).new(@@services[name].merge({"id"=>name}))
  end  
end
class ServiceList
  private_class_method :new
  @@services = nil
  
  def self.get(name)
    @@services = YAML.load_file(RAILS_ROOT+"/config/services.yml") unless @@services

    if (@@services[name].nil?)
      raise NameError.new("No such service named #{name} has been loaded. Check config/services.yml", name)
    end
    
    require 'service_adaptors/'+@@services[name]["type"].underscore
    
    className = @@services[name]["type"]
    classConst = Kernel.const_get(className)\
    
    return classConst.new(@@services[name].merge({"id"=>name}))
  end
end
Check for a service name referenced but not loaded from services.yml, and raise a meaningful exception.
Check for a service name referenced but not loaded from services.yml, and raise a meaningful exception.

