Class: Collective::LifecycleObserver

Inherits:
Utilities::ObserverBase show all
Defined in:
lib/collective/lifecycle_observer.rb

Instance Attribute Summary collapse

Attributes inherited from Utilities::ObserverBase

#subject

Instance Method Summary collapse

Methods inherited from Utilities::ObserverBase

camelize, #focus, #notify, resolve

Constructor Details

#initialize(key, registry) ⇒ LifecycleObserver

Returns a new instance of LifecycleObserver.



8
9
10
11
# File 'lib/collective/lifecycle_observer.rb', line 8

def initialize( key, registry )
  @key      = key
  @registry = registry
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/collective/lifecycle_observer.rb', line 5

def key
  @key
end

#registryObject (readonly)

Returns the value of attribute registry.



6
7
8
# File 'lib/collective/lifecycle_observer.rb', line 6

def registry
  @registry
end

Instance Method Details

#worker_heartbeat(upcount = 0) ⇒ Object



17
18
19
# File 'lib/collective/lifecycle_observer.rb', line 17

def worker_heartbeat( upcount = 0 )
  registry.update( key )
end

#worker_startedObject



13
14
15
# File 'lib/collective/lifecycle_observer.rb', line 13

def worker_started
  registry.register( key )
end

#worker_stoppedObject



21
22
23
# File 'lib/collective/lifecycle_observer.rb', line 21

def worker_stopped
  registry.unregister( key )
end