Class: Mutant::Matcher::ScopeMethods

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

Overview

Abstract base class for matcher that returns subjects extracted from scope methods

Direct Known Subclasses

Instance, Singleton

Defined Under Namespace

Classes: Instance, Singleton

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mutant::Matcher

from_string, #identification, parse

Instance Attribute Details

#scopeClass, Model (readonly)

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 scope

Returns:

  • (Class, Model)


13
14
15
# File 'lib/mutant/matcher/scope_methods.rb', line 13

def scope
  @scope
end

Class Method Details

.method_names(object) ⇒ Enumerable<Symbol>

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 names

Parameters:

  • object (Object)

Returns:

  • (Enumerable<Symbol>)


66
67
68
69
70
# File 'lib/mutant/matcher/scope_methods.rb', line 66

def self.method_names(object)
  object.public_instance_methods(false)   +
  object.private_instance_methods(false)  +
  object.protected_instance_methods(false)
end

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



25
26
27
28
29
30
31
32
33
# File 'lib/mutant/matcher/scope_methods.rb', line 25

def each(&block)
  return to_enum unless block_given?

  methods.each do |method|
    emit_matches(method, &block)
  end

  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)


54
55
56
# File 'lib/mutant/matcher/scope_methods.rb', line 54

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
# File 'lib/mutant/matcher/scope_methods.rb', line 41

def methods
  method_names.map do |name|
    access(name)
  end
end