Class: Henitai::Mutant::Activator

Inherits:
Object
  • Object
show all
Includes:
ConstantRedefinitionFilter
Defined in:
lib/henitai/mutant/activator.rb

Overview

Activates a mutant inside the forked child process.

Defined Under Namespace

Modules: ConstantRedefinitionFilter

Constant Summary collapse

SERIALIZER_METHODS =
{
  arg: :argument_parameter_fragment,
  optarg: :optional_parameter_fragment,
  restarg: :rest_parameter_fragment,
  kwarg: :keyword_parameter_fragment,
  kwoptarg: :optional_keyword_parameter_fragment,
  kwrestarg: :keyword_rest_parameter_fragment,
  blockarg: :block_parameter_fragment,
  forward_arg: :forward_parameter_fragment
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ConstantRedefinitionFilter

#warn

Class Method Details

.activate!(mutant) ⇒ Object



37
38
39
# File 'lib/henitai/mutant/activator.rb', line 37

def self.activate!(mutant)
  new.activate!(mutant)
end

Instance Method Details

#activate!(mutant) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/henitai/mutant/activator.rb', line 41

def activate!(mutant)
  subject = mutant.subject
  raise ArgumentError, "Cannot activate wildcard subjects" if subject.method_name.nil?

  target = target_for(subject)
  Henitai::WarningSilencer.silence do
    target.class_eval(method_source(mutant), __FILE__, __LINE__ + 1)
    nil
  end
rescue Unparser::UnsupportedNodeError
  :compile_error
end