Method: BrB::Tunnel::Shared#treat_callback_return
- Defined in:
- lib/brb/tunnel/shared.rb
#treat_callback_return(ret, key, nb_out) ⇒ Object
Call a callback if present, return true if exists Non blocking action, use EM.defer
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/brb/tunnel/shared.rb', line 110 def treat_callback_return(ret, key, nb_out) if b = get_callback(key, nb_out) EM.defer do # With arity, handle multiple block arguments or no arguments b.arity == 1 ? b.call(ret) : (b.arity == 0 ? b.call : b.call(*ret)) end # A callback has been found and called, return true return true end # No callback, do nothing return nil end |