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, #respond_to_missing?

Constructor Details

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

Returns a new instance of NullStatus.



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

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.



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

def bid
  @bid
end

Instance Method Details

#failuresObject



67
68
69
# File 'lib/rspec/sidekiq/batch.rb', line 67

def failures
  0
end

#joinObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rspec/sidekiq/batch.rb', line 71

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



89
90
91
# File 'lib/rspec/sidekiq/batch.rb', line 89

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