class FFWD::Plugin::GoogleCloud::CallbackProxy

Attributes

error[R]

Public Class Methods

new() click to toggle source
# File lib/ffwd/plugin/google_cloud/hook.rb, line 328
def initialize
  @callbacks = []
  @errbacks = []
  @called = false
end

Public Instance Methods

call() click to toggle source
# File lib/ffwd/plugin/google_cloud/hook.rb, line 352
def call
  @callbacks.each(&:call).clear
  @called = :call
end
callback(&block) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/ffwd/plugin/google_cloud/hook.rb, line 369
def into other
  errback { other.err error }
  callback { other.call }
end