Class: Mutant::Matcher::Methods

Inherits:
Mutant::Matcher show all
Includes:
AbstractType
Defined in:
lib/mutant/matcher/methods.rb

Overview

Abstract base class for matcher that returns method subjects from scope

Direct Known Subclasses

Instance, Singleton

Defined Under Namespace

Classes: Instance, Singleton

Instance Method Summary collapse

Methods inherited from Mutant::Matcher

build, #identification

Instance Method Details

#each(&block) ⇒ self, Enumerator<Subject>

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 subjects

Returns:

  • (self)

    if block given

  • (Enumerator<Subject>)

    otherwise



17
18
19
20
21
22
23
# File 'lib/mutant/matcher/methods.rb', line 17

def each(&block)
  return to_enum unless block_given?

  subjects.each(&block)

  self
end

#matcherClass:Matcher::Method

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.

Return method matcher class

Returns:

  • (Class:Matcher::Method)


31
32
33
# File 'lib/mutant/matcher/methods.rb', line 31

def matcher
  self.class::MATCHER
end

#methodsEnumerable<Method, UnboundMethod>

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.

Return methods

Returns:

  • (Enumerable<Method, UnboundMethod>)


41
42
43
44
45
46
# File 'lib/mutant/matcher/methods.rb', line 41

def methods
  candidate_names.each_with_object([]) do |name, methods|
    method = access(name)
    methods << method if method.owner.equal?(candidate_scope)
  end
end