Class: Guacamole::Callbacks::CallbackProxy
- Inherits:
-
Object
- Object
- Guacamole::Callbacks::CallbackProxy
- Defined in:
- lib/guacamole/callbacks.rb
Overview
A proxy class around the callback class itself.
The sole reason for its existence is to specify multiple callback runs at once. The alternative
would have been to nest the run_callbacks
calls within the caller. It was decided to have bit
more complex proxy class to hide those details from the caller.
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
Instance Method Summary collapse
-
#initialize(callbacks) ⇒ CallbackProxy
constructor
Create a new proxy with the original callbacks class as input.
-
#run_callbacks(*callbacks_to_run) { ... } ⇒ Object
Runs the given kinds of callbacks.
Constructor Details
#initialize(callbacks) ⇒ CallbackProxy
Create a new proxy with the original callbacks class as input
184 185 186 |
# File 'lib/guacamole/callbacks.rb', line 184 def initialize(callbacks) @callbacks = callbacks end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
179 180 181 |
# File 'lib/guacamole/callbacks.rb', line 179 def callbacks @callbacks end |
Instance Method Details
#run_callbacks(*callbacks_to_run) { ... } ⇒ Object
Runs the given kinds of callbacks
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/guacamole/callbacks.rb', line 192 def run_callbacks(*callbacks_to_run, &block) outer = callbacks_to_run.pop if callbacks_to_run.empty? @callbacks.run_callbacks(outer, &block) else @callbacks = run_callbacks(*callbacks_to_run) do @callbacks.run_callbacks(outer, &block) end end end |