Class: Mutant::Matcher::Builder
- Inherits:
-
Object
- Object
- Mutant::Matcher::Builder
- Includes:
- AST::Sexp
- Defined in:
- lib/mutant/matcher/builder.rb
Overview
Builder for complex matchers
Instance Method Summary collapse
-
#add_match_expression(expression) ⇒ self
private
Add a match expression.
-
#add_subject_ignore(expression) ⇒ self
private
Add a subject ignore.
-
#add_subject_selector(attribute, value) ⇒ self
private
Add a subject selector.
-
#initialize(env) ⇒ undefined
constructor
private
Initalize object.
-
#matcher ⇒ Mutant::Matcher
private
Return generated matcher.
Constructor Details
#initialize(env) ⇒ undefined
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.
Initalize object
15 16 17 18 19 20 |
# File 'lib/mutant/matcher/builder.rb', line 15 def initialize(env) super @matchers = [] @subject_ignores = [] @subject_selectors = [] end |
Instance Method Details
#add_match_expression(expression) ⇒ 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.
Add a match expression
56 57 58 59 |
# File 'lib/mutant/matcher/builder.rb', line 56 def add_match_expression(expression) @matchers << expression.matcher(env) self end |
#add_subject_ignore(expression) ⇒ 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.
Add a subject ignore
30 31 32 33 |
# File 'lib/mutant/matcher/builder.rb', line 30 def add_subject_ignore(expression) @subject_ignores << expression.matcher(env) self end |
#add_subject_selector(attribute, value) ⇒ 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.
Add a subject selector
43 44 45 46 |
# File 'lib/mutant/matcher/builder.rb', line 43 def add_subject_selector(attribute, value) @subject_selectors << Morpher.compile(s(:eql, s(:attribute, attribute), s(:static, value))) self end |
#matcher ⇒ Mutant::Matcher
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 generated matcher
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/mutant/matcher/builder.rb', line 67 def matcher if @matchers.empty? return Matcher::Null.new end matcher = Matcher::Chain.build(@matchers) if predicate Matcher::Filter.new(matcher, predicate) else matcher end end |