Class: TTK::Monitors::Server

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbUndumped
Defined in:
lib/ttk/monitors/Server.rb

Defined Under Namespace

Modules: Notification Classes: Notifier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, monitor, max_observer) ⇒ Server

module Notification



28
29
30
31
32
33
34
35
# File 'lib/ttk/monitors/Server.rb', line 28

def initialize(service, monitor, max_observer)
  @service = service
  @max_observer = max_observer
  @mutex = Mutex.new
  @monitor = monitor
  @notifier = Notifier.new
  @notifier.add_observer(@service)
end

Instance Attribute Details

#max_observerObject (readonly)

Returns the value of attribute max_observer.



37
38
39
# File 'lib/ttk/monitors/Server.rb', line 37

def max_observer
  @max_observer
end

Instance Method Details

#add_observer(observer) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/ttk/monitors/Server.rb', line 43

def add_observer(observer)
  @mutex.synchronize do
    if @monitor.count_observers < @max_observer
      @notifier.changed
      @notifier.notify_observers(Notification::ADD_OBSERVER)
      @monitor.add_observer(observer)
    end
  end
end

#count_observersObject



39
40
41
# File 'lib/ttk/monitors/Server.rb', line 39

def count_observers
  @monitor.count_observers
end

#requestsObject

List all requests available on this front tester.



54
55
56
57
58
59
# File 'lib/ttk/monitors/Server.rb', line 54

def requests
  o = Tester.superclass.new
  public_methods.select do |meth|
    not (o.respond_to?(meth) or meth.to_s =~ /^_/)
  end
end

#uriObject



61
62
63
# File 'lib/ttk/monitors/Server.rb', line 61

def uri
  @service.uri
end