Class: FFWD::Plugin::GoogleCloud::CallbackProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/ffwd/plugin/google_cloud/hook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCallbackProxy

Returns a new instance of CallbackProxy.



299
300
301
302
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 299

def initialize
  @callbacks = []
  @errbacks = []
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



297
298
299
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 297

def error
  @error
end

Instance Method Details

#callObject



312
313
314
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 312

def call
  @callbacks.each(&:call).clear
end

#callback(&block) ⇒ Object



304
305
306
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 304

def callback &block
  @callbacks << block
end

#err(error) ⇒ Object



316
317
318
319
320
321
322
323
324
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 316

def err error
  return if @errbacks.empty?

  @error = error

  @errbacks.each do |cb|
    cb.call error
  end.clear
end

#errback(&block) ⇒ Object



308
309
310
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 308

def errback &block
  @errbacks << block
end

#into(other) ⇒ Object



326
327
328
329
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 326

def into other
  errback { other.err error }
  callback { other.call }
end