Class: SerfHandlerProxy
- Inherits:
-
SerfHandler
- Object
- SerfHandler
- SerfHandlerProxy
- Defined in:
- lib/serf_handler.rb
Overview
Proxy for handling serf event
Instance Attribute Summary
Attributes inherited from SerfHandler
Instance Method Summary collapse
- #good_handler ⇒ Object
-
#initialize(log_file = nil) ⇒ SerfHandlerProxy
constructor
A new instance of SerfHandlerProxy.
- #register(role, handler) ⇒ Object
- #run ⇒ Object
Methods inherited from SerfHandler
#create_logger, #error, #info, #response, #set_logging, #warn
Constructor Details
#initialize(log_file = nil) ⇒ SerfHandlerProxy
Returns a new instance of SerfHandlerProxy.
64 65 66 67 |
# File 'lib/serf_handler.rb', line 64 def initialize(log_file = nil) super(log_file) @handlers = {} end |
Instance Method Details
#good_handler ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/serf_handler.rb', line 73 def good_handler handler = nil if @handlers.include?(@role) handler = @handlers[@role] elsif @handlers.include?('default') handler = @handlers['default'] end handler end |
#register(role, handler) ⇒ Object
69 70 71 |
# File 'lib/serf_handler.rb', line 69 def register(role, handler) @handlers[role] = handler end |
#run ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/serf_handler.rb', line 83 def run if (the_handler = good_handler) begin the_handler.send @event rescue NoMethodError warn "#{@event} event not implemented by class" end else info 'no handler for role' end end |