Class: Collective::LifecycleObserver
- Inherits:
-
Utilities::ObserverBase
- Object
- Utilities::ObserverBase
- Collective::LifecycleObserver
- Defined in:
- lib/collective/lifecycle_observer.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Attributes inherited from Utilities::ObserverBase
Instance Method Summary collapse
-
#initialize(key, registry) ⇒ LifecycleObserver
constructor
A new instance of LifecycleObserver.
- #worker_heartbeat(upcount = 0) ⇒ Object
- #worker_started ⇒ Object
- #worker_stopped ⇒ Object
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/collective/lifecycle_observer.rb', line 5 def key @key end |
#registry ⇒ Object (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_started ⇒ Object
13 14 15 |
# File 'lib/collective/lifecycle_observer.rb', line 13 def worker_started registry.register( key ) end |
#worker_stopped ⇒ Object
21 22 23 |
# File 'lib/collective/lifecycle_observer.rb', line 21 def worker_stopped registry.unregister( key ) end |