Class: ServiceMgr

Inherits:
AppMgr
  • Object
show all
Defined in:
lib/onedrb.rb

Overview

Note: The Server object can also use a default ServiceMgr object. Which allows multiple services (user-defined objects) to be hosted dynamically. OneDrb recommended port: 57844 (as this port is recognised by the RSC gem)

Instance Method Summary collapse

Constructor Details

#initialize(rsf: nil, debug: false) ⇒ ServiceMgr

Returns a new instance of ServiceMgr.



19
20
21
22
# File 'lib/onedrb.rb', line 19

def initialize(rsf: nil, debug: false)
  super(rsf: rsf, type: 'service', debug: debug)
  @services = @app
end

Instance Method Details

#call(service, methodname, *a) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/onedrb.rb', line 25

def call(service, methodname, *a)

  return @services[service.to_sym][:running] unless methodname
  proc1 = @services[service.to_sym][:running].method(methodname.to_sym)
  a.last.is_a?(Hash) ? proc1.call(*a[0..-2], **a.last) : proc1.call(*a)

end

#services ⇒ Object

OneDRb version 2; Allows multiple user-defined objects to be served from 1 DRb service

not used by any client, but may be in future

def odrb2?() true end



43
44
45
46
47
48
# File 'lib/onedrb.rb', line 43

def services()
  @services.map do |key, object|
    next unless object[:running]
    [key, object[:running].public_methods - Object.public_methods]
  end.compact
end