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.



260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 260

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.



258
259
260
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 258

def error
  @error
end

Instance Method Details

#callObject



281
282
283
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 281

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

#callback(&block) ⇒ Object



273
274
275
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 273

def callback &block
  @callbacks << block
end

#err(error) ⇒ Object



285
286
287
288
289
290
291
292
293
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 285

def err error
  return if @errbacks.empty?

  @error = error

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

#errback(&block) ⇒ Object



277
278
279
# File 'lib/ffwd/plugin/google_cloud/hook.rb', line 277

def errback &block
  @errbacks << block
end