Class: FFWD::Plugin::GoogleCloud::SingleProxy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ SingleProxy

Returns a new instance of SingleProxy.



289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 289

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

  p.callback do
    call
  end

  p.errback do |error|
    err error
  end
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



287
288
289
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 287

def error
  @error
end

Instance Method Details

#callObject



310
311
312
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 310

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

#callback(&block) ⇒ Object



302
303
304
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 302

def callback &block
  @callbacks << block
end

#err(error) ⇒ Object



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

def err error
  return if @errbacks.empty?

  @error = error

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

#errback(&block) ⇒ Object



306
307
308
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 306

def errback &block
  @errbacks << block
end