Class: FFWD::Plugin::GoogleCloud::CallbackProxy
- Inherits:
-
Object
- Object
- FFWD::Plugin::GoogleCloud::CallbackProxy
- Defined in:
- lib/ffwd/plugin/google_cloud/hook.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #call ⇒ Object
- #callback(&block) ⇒ Object
- #err(error) ⇒ Object
- #errback(&block) ⇒ Object
-
#initialize ⇒ CallbackProxy
constructor
A new instance of CallbackProxy.
- #into(other) ⇒ Object
Constructor Details
#initialize ⇒ CallbackProxy
Returns a new instance of CallbackProxy.
328 329 330 331 332 |
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 328 def initialize @callbacks = [] @errbacks = [] @called = false end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
326 327 328 |
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 326 def error @error end |
Instance Method Details
#call ⇒ Object
352 353 354 355 |
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 352 def call @callbacks.each(&:call).clear @called = :call end |
#callback(&block) ⇒ Object
334 335 336 337 338 339 340 341 |
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 334 def callback &block if @called block.call if @called == :call return end @callbacks << block end |
#err(error) ⇒ Object
357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 357 def err error return if @errbacks.empty? @error = error @errbacks.each do |cb| cb.call error end.clear @called = :err end |
#errback(&block) ⇒ Object
343 344 345 346 347 348 349 350 |
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 343 def errback &block if @called block.call if @called == :err return end @errbacks << block end |
#into(other) ⇒ Object
369 370 371 372 |
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 369 def into other errback { other.err error } callback { other.call } end |