Class: Mocha::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/debugger/test/mocha_extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*blocks) ⇒ Call

Returns a new instance of Call.



54
55
56
# File 'lib/debugger/test/mocha_extensions.rb', line 54

def initialize(*blocks)
  @blocks = [ *blocks ]
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



52
53
54
# File 'lib/debugger/test/mocha_extensions.rb', line 52

def blocks
  @blocks
end

Instance Method Details

#+(other) ⇒ Object



66
67
68
# File 'lib/debugger/test/mocha_extensions.rb', line 66

def +(other)
  self.class.new(*(@blocks + other.blocks))
end

#next(arguments, &block) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/debugger/test/mocha_extensions.rb', line 58

def next(arguments, &block)
  case @blocks.length
    when 0 then nil
    when 1 then @blocks.first.call(*arguments, &block)
    else @blocks.shift.call(*arguments, &block)
  end
end