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.



55
56
57
58
# File 'lib/rspec/sidekiq/batch.rb', line 55

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.



53
54
55
# File 'lib/rspec/sidekiq/batch.rb', line 53

def bid
  @bid
end

Instance Method Details

#failuresObject



60
61
62
# File 'lib/rspec/sidekiq/batch.rb', line 60

def failures
  0
end

#joinObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rspec/sidekiq/batch.rb', line 64

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



82
83
84
# File 'lib/rspec/sidekiq/batch.rb', line 82

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