File: instance_methods.rb

package info (click to toggle)
ruby-mocha 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,652 kB
  • sloc: ruby: 12,324; javascript: 499; makefile: 14
file content (28 lines) | stat: -rw-r--r-- 715 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

require 'mocha/parameter_matchers/base_methods'
require 'mocha/parameter_matchers/equals'
require 'mocha/parameter_matchers/positional_or_keyword_hash'

module Mocha
  module ParameterMatchers
    # @private
    module InstanceMethods
      # @private
      def to_matcher(expectation: nil, top_level: false, last: false)
        if is_a?(BaseMethods)
          self
        elsif Hash === self && top_level
          Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self, expectation, last)
        else
          Mocha::ParameterMatchers::Equals.new(self)
        end
      end
    end
  end
end

# @private
class Object
  include Mocha::ParameterMatchers::InstanceMethods
end