Class: Evilution::Mutator::Registry Private
- Inherits:
-
Object
- Object
- Evilution::Mutator::Registry
- Defined in:
- lib/evilution/mutator/registry.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- STRICT_EXTRA_OPERATORS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ Evilution::Mutator::Operator::PredicateToNil ].freeze
Class Method Summary collapse
- .default ⇒ Object private
- .for_profile(profile) ⇒ Object private
Instance Method Summary collapse
-
#initialize ⇒ Registry
constructor
private
A new instance of Registry.
- #mutations_for(subject, filter: nil, operator_options: {}) ⇒ Object private
- #operator_count ⇒ Object private
- #operators ⇒ Object private
- #register(operator_class) ⇒ Object private
Constructor Details
#initialize ⇒ Registry
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.
Returns a new instance of Registry.
107 108 109 |
# File 'lib/evilution/mutator/registry.rb', line 107 def initialize @operators = [] end |
Class Method Details
.default ⇒ Object
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.
.for_profile(profile) ⇒ Object
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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/evilution/mutator/registry.rb', line 10 def self.for_profile(profile) unless profile.is_a?(Symbol) || profile.is_a?(String) raise ArgumentError, "unknown profile: #{profile.inspect} (expected :default or :strict)" end case profile.to_sym when :default then default when :strict registry = default STRICT_EXTRA_OPERATORS.each { |op| registry.register(op) } registry else raise ArgumentError, "unknown profile: #{profile.inspect} (expected :default or :strict)" end end |
Instance Method Details
#mutations_for(subject, filter: nil, operator_options: {}) ⇒ Object
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.
116 117 118 119 120 121 |
# File 'lib/evilution/mutator/registry.rb', line 116 def mutations_for(subject, filter: nil, operator_options: {}) @operators.flat_map do |operator_class| operator = build_operator(operator_class, ) operator.call(subject, filter: filter) end end |
#operator_count ⇒ Object
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.
123 124 125 |
# File 'lib/evilution/mutator/registry.rb', line 123 def operator_count @operators.length end |
#operators ⇒ Object
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.
127 128 129 |
# File 'lib/evilution/mutator/registry.rb', line 127 def operators @operators.dup end |
#register(operator_class) ⇒ Object
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.
111 112 113 114 |
# File 'lib/evilution/mutator/registry.rb', line 111 def register(operator_class) @operators << operator_class self end |