Class: Steep::Server::Master::GroupHandler
- Defined in:
- lib/steep/server/master.rb
Instance Attribute Summary collapse
-
#completion_handler ⇒ Object
readonly
Returns the value of attribute completion_handler.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #<<(handler) ⇒ Object
- #completed? ⇒ Boolean
-
#initialize ⇒ GroupHandler
constructor
A new instance of GroupHandler.
- #on_completion(&block) ⇒ Object
- #process_response(message) ⇒ Object
Constructor Details
#initialize ⇒ GroupHandler
Returns a new instance of GroupHandler.
46 47 48 49 |
# File 'lib/steep/server/master.rb', line 46 def initialize() @handlers = {} @completion_handler = nil end |
Instance Attribute Details
#completion_handler ⇒ Object (readonly)
Returns the value of attribute completion_handler.
44 45 46 |
# File 'lib/steep/server/master.rb', line 44 def completion_handler @completion_handler end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
43 44 45 |
# File 'lib/steep/server/master.rb', line 43 def handlers @handlers end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
42 43 44 |
# File 'lib/steep/server/master.rb', line 42 def request @request end |
Instance Method Details
#<<(handler) ⇒ Object
69 70 71 |
# File 'lib/steep/server/master.rb', line 69 def <<(handler) handlers[handler.request[:id]] = handler end |
#completed? ⇒ Boolean
65 66 67 |
# File 'lib/steep/server/master.rb', line 65 def completed? handlers.each_value.all? {|handler| handler.completed? } end |
#on_completion(&block) ⇒ Object
73 74 75 |
# File 'lib/steep/server/master.rb', line 73 def on_completion(&block) @completion_handler = block end |
#process_response(message) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/steep/server/master.rb', line 51 def process_response() if handler = handlers[[:id]] handler.process_response() if completed? completion_handler&.call(handlers.values) end true else false end end |