Class: Mutant::Matcher::Method

Inherits:
Mutant::Matcher show all
Includes:
Adamantium::Flat
Defined in:
lib/mutant/matcher/method.rb,
lib/mutant/matcher/method/finder.rb,
lib/mutant/matcher/method/instance.rb,
lib/mutant/matcher/method/singleton.rb

Overview

Matcher for subjects that are a specific method

Direct Known Subclasses

Instance, Singleton

Defined Under Namespace

Classes: Finder, Instance, Singleton

Constant Summary collapse

SKIP_METHODS =

Methods within rbx kernel directory are precompiled and their source cannot be accessed via reading source location

%w[kernel/ (eval)].freeze
BLACKLIST =
/\A#{Regexp.union(*SKIP_METHODS)}/.freeze

Instance Method Summary collapse

Methods inherited from Mutant::Matcher

build, each, #identification

Instance Method Details

#eachEnumerable<Subject>, self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enumerate matches

Returns:

  • (Enumerable<Subject>)

    if no block given

  • (self)

    otherwise



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mutant/matcher/method.rb', line 24

def each
  return to_enum unless block_given?

  unless skip?
    if subject
      yield subject
    else
      message = sprintf(
        'Cannot find definition of: %s in %s',
        identification,
        source_location.join(':')
      )
      $stderr.puts(message)
    end
  end

  self
end