Class: SerfHandlerProxy
- Inherits:
-
SerfHandler
- Object
- SerfHandler
- SerfHandlerProxy
- Defined in:
- lib/serf_handler.rb
Instance Attribute Summary
Attributes inherited from SerfHandler
Instance Method Summary collapse
- #get_klass ⇒ Object
-
#initialize(logger = nil) ⇒ SerfHandlerProxy
constructor
A new instance of SerfHandlerProxy.
- #register(role, handler) ⇒ Object
- #run ⇒ Object
Methods inherited from SerfHandler
Constructor Details
#initialize(logger = nil) ⇒ SerfHandlerProxy
Returns a new instance of SerfHandlerProxy.
27 28 29 30 |
# File 'lib/serf_handler.rb', line 27 def initialize(logger=nil) super(logger) @handlers = {} end |
Instance Method Details
#get_klass ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/serf_handler.rb', line 36 def get_klass() klass = false if @handlers.include?(@role) klass = @handlers[@role] elsif @handlers.include?('default') klass = @handlers['default'] end klass end |
#register(role, handler) ⇒ Object
32 33 34 |
# File 'lib/serf_handler.rb', line 32 def register(role, handler) @handlers[role] = handler end |
#run ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/serf_handler.rb', line 46 def run() unless klass = get_klass log "no handler for role" else begin klass.send @event rescue NoMethodError => e log "event not implemented by class" end end end |