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.6.0 lib/mocha/return_values.rb
mocha-2.5.0 lib/mocha/return_values.rb
mocha-2.4.5 lib/mocha/return_values.rb
mocha-2.4.4 lib/mocha/return_values.rb
mocha-2.4.3 lib/mocha/return_values.rb
mocha-2.4.2 lib/mocha/return_values.rb
mocha-2.4.1 lib/mocha/return_values.rb
mocha-2.4.0 lib/mocha/return_values.rb
mocha-2.2.0 lib/mocha/return_values.rb
mocha-2.1.0 lib/mocha/return_values.rb
mocha-2.0.4 lib/mocha/return_values.rb
mocha-2.0.3 lib/mocha/return_values.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/mocha-2.0.2/lib/mocha/return_values.rb
mocha-2.0.2 lib/mocha/return_values.rb
mocha-1.16.1 lib/mocha/return_values.rb
mocha-1.15.1 lib/mocha/return_values.rb
mocha-2.0.1 lib/mocha/return_values.rb
mocha-2.0.0 lib/mocha/return_values.rb
mocha-1.16.0 lib/mocha/return_values.rb
mocha-2.0.0.alpha.1 lib/mocha/return_values.rb