Class: RSpec::Sidekiq::NullStatus

Inherits:
NullObject show all
Defined in:
lib/rspec/sidekiq/batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from NullObject

#method_missing

Constructor Details

#initialize(bid = SecureRandom.hex(8), callbacks = []) ⇒ NullStatus

Returns a new instance of NullStatus.



37
38
39
40
# File 'lib/rspec/sidekiq/batch.rb', line 37

def initialize(bid = SecureRandom.hex(8), callbacks = [])
  @bid = bid
  @callbacks = callbacks
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RSpec::Sidekiq::NullObject

Instance Attribute Details

#bidObject (readonly)

Returns the value of attribute bid.



35
36
37
# File 'lib/rspec/sidekiq/batch.rb', line 35

def bid
  @bid
end

Instance Method Details

#failuresObject



42
43
44
# File 'lib/rspec/sidekiq/batch.rb', line 42

def failures
  0
end

#joinObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/rspec/sidekiq/batch.rb', line 46

def join
  ::Sidekiq::Worker.drain_all

  @callbacks.each do |event, callback, options|
    if event != :success || failures == 0
      case callback
      when Class    
        callback.new.send("on_#{event}", self, options)
      when String
        klass, meth = callback.split('#')
        klass.constantize.new.send(meth, self, options)
      else
        raise ArgumentError, 'Unsupported callback notation'
      end
    end
  end
end

#totalObject



64
65
66
# File 'lib/rspec/sidekiq/batch.rb', line 64

def total
  ::Sidekiq::Worker.jobs.size
end