class Mocha::ParameterMatchers::Optionally

Parameter matcher which allows optional parameters to be specified.

def initialize(*parameters)

Other tags:
    Private: -
def initialize(*parameters)
  @matchers = parameters.map { |parameter| parameter.to_matcher }
end

def matches?(available_parameters)

Other tags:
    Private: -
def matches?(available_parameters)
  index = 0
  while (available_parameters.length > 0) && (index < @matchers.length) do
    matcher = @matchers[index]
    return false unless matcher.matches?(available_parameters)
    index += 1
  end
  return true
end

def mocha_inspect

Other tags:
    Private: -
def mocha_inspect
  "optionally(#{@matchers.map { |matcher| matcher.mocha_inspect }.join(", ") })"
end