Class: PubControlCallbackHandler
- Inherits:
-
Object
- Object
- PubControlCallbackHandler
- Defined in:
- lib/pccbhandler.rb
Overview
format.rb
~~~~~~~~~
This module implements the PubControlCallbackHandler class.
:copyright: (c) 2014 by Konstantin Bokarius.
:license: MIT, see LICENSE for more details.
Instance Method Summary collapse
- #handler(success, message) ⇒ Object
-
#handler_method_symbol ⇒ Object
TODO: how to get handler symbol without this method?.
-
#initialize(num_calls, callback) ⇒ PubControlCallbackHandler
constructor
A new instance of PubControlCallbackHandler.
Constructor Details
#initialize(num_calls, callback) ⇒ PubControlCallbackHandler
Returns a new instance of PubControlCallbackHandler.
8 9 10 11 12 13 |
# File 'lib/pccbhandler.rb', line 8 def initialize(num_calls, callback) @num_calls = num_calls @callback = callback @success = true = nil end |
Instance Method Details
#handler(success, message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pccbhandler.rb', line 15 def handler(success, ) if !success and @success @success = false = end @num_calls -= 1 if @num_calls <= 0 @callback.call(@success, ) end end |
#handler_method_symbol ⇒ Object
TODO: how to get handler symbol without this method?
27 28 29 |
# File 'lib/pccbhandler.rb', line 27 def handler_method_symbol return method(:handler) end |