Class: Mutant::Loader Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mutant/loader.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.

Defined Under Namespace

Classes: Result

Constant Summary collapse

FROZEN_STRING_FORMAT =

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.

"# frozen_string_literal: true\n%s"
VOID_VALUE_REGEXP =

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.

/\A[^:]+:\d+: void value expression/.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(*arguments) ⇒ Result

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.

Call loader

Returns:



27
28
29
# File 'lib/mutant/loader.rb', line 27

def self.call(*arguments)
  new(*arguments).call
end

Instance Method Details

#callResult

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.

Call loader

One off the very few valid uses of eval ever.

rubocop:disable Metrics/MethodLength

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mutant/loader.rb', line 38

def call
  kernel.eval(
    FROZEN_STRING_FORMAT % source,
    binding,
    subject.source_path.to_s,
    subject.source_line
  )
rescue SyntaxError => exception
  # rubocop:disable Style/GuardClause
  if VOID_VALUE_REGEXP.match?(exception.message)
    Result::VoidValue.instance
  else
    raise
  end
else
  Result::Success.instance
end