Class: StripeMock::ErrorQueue

Inherits:
Object
  • Object
show all
Extended by:
DRb::DRbUndumped
Includes:
DRb::DRbUndumped
Defined in:
lib/stripe_mock/error_queue.rb

Instance Method Summary collapse

Constructor Details

#initializeErrorQueue

Returns a new instance of ErrorQueue.



8
9
10
# File 'lib/stripe_mock/error_queue.rb', line 8

def initialize
  @queue = []
end

Instance Method Details

#dequeueObject



22
23
24
# File 'lib/stripe_mock/error_queue.rb', line 22

def dequeue
  @queue.shift
end

#error_for_handler_name(handler_name) ⇒ Object



16
17
18
19
20
# File 'lib/stripe_mock/error_queue.rb', line 16

def error_for_handler_name(handler_name)
  return nil if @queue.count == 0
  triggers = @queue.first
  (triggers.assoc(:all) || triggers.assoc(handler_name) || [])[1]
end

#queue(error, handler_names) ⇒ Object



12
13
14
# File 'lib/stripe_mock/error_queue.rb', line 12

def queue(error, handler_names)
  @queue << handler_names.map {|n| [n, error]}
end