Module: SADI

Defined in:
lib/sadi-rb/server.rb,
lib/sadi-rb/services.rb,
lib/sadi-rb/converter.rb,
lib/sadi-rb/base_service.rb,
lib/sadi-rb/synchronous_service.rb,
lib/sadi-rb/asynchronous_service.rb

Defined Under Namespace

Modules: AsynchronousService, BaseService, Converter, SynchronousService Classes: Server

Class Method Summary collapse

Class Method Details

.register_service(name, object) ⇒ Object



7
8
9
# File 'lib/sadi-rb/services.rb', line 7

def register_service(name, object)
  services[name] = object
end

.reload_servicesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sadi-rb/services.rb', line 15

def reload_services
  @@services = {}

  (SADI::SynchronousService.classes | SADI::AsynchronousService.classes).each do |service|
    if service.respond_to? 'service_name'
      name = service.service_name
      puts "Warning: service #{@@services[name]} already using name '#{name}', overwriting" if @@services[name]
      @@services[name] = service
    elsif service.instance_methods.include? :service_name
      service = service.new
      name = service.service_name
      puts "Warning: service #{@@services[name]} already using name '#{name}', overwriting" if @@services[name]
      @@services[name] = service
    else
      raise "service #{service} does not define a proper interface"
    end
  end
end

.service_for(name) ⇒ Object



3
4
5
# File 'lib/sadi-rb/services.rb', line 3

def service_for(name)
  services[name]
end

.servicesObject



11
12
13
# File 'lib/sadi-rb/services.rb', line 11

def services
  @@services ||= {}
end