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.



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

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.



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

def bid
  @bid
end

Instance Method Details

#failuresObject



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

def failures
  0
end

#joinObject



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

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



85
86
87
# File 'lib/rspec/sidekiq/batch.rb', line 85

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