Sha256: fa5796a9cc53bf52ec6b74e6de69633a0708d1599be1e61bf1f6321fc67d43e4

Contents?: true

Size: 533 Bytes

Versions: 33

Compression:

Stored size: 533 Bytes

Contents

require 'mocha/single_return_value'

module Mocha
  class ReturnValues
    def self.build(*values)
      new(*values.map { |value| SingleReturnValue.new(value) })
    end

    attr_accessor :values

    def initialize(*values)
      @values = values
    end

    def next(invocation)
      case @values.length
      when 0 then nil
      when 1 then @values.first.evaluate(invocation)
      else @values.shift.evaluate(invocation)
      end
    end

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

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
mocha-2.0.0.alpha lib/mocha/return_values.rb
mocha-1.15.0 lib/mocha/return_values.rb
mocha-1.14.0 lib/mocha/return_values.rb
mocha-1.13.0 lib/mocha/return_values.rb
mocha-1.12.0 lib/mocha/return_values.rb
mocha-1.11.2 lib/mocha/return_values.rb
mocha-1.11.1 lib/mocha/return_values.rb
mocha-1.11.0 lib/mocha/return_values.rb
mocha-1.10.2 lib/mocha/return_values.rb
mocha-1.10.1 lib/mocha/return_values.rb
mocha-1.10.0 lib/mocha/return_values.rb
mocha-1.10.0.beta.1 lib/mocha/return_values.rb
mocha-1.10.0.alpha lib/mocha/return_values.rb