Module: Mutant::RequireHighjack

Defined in:
lib/mutant/require_highjack.rb

Overview

Require highjack

Class Method Summary collapse

Class Method Details

.call(target, callback) ⇒ #call

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.

Install require callback

Parameters:

  • target (Module)
  • callback (#call)

Returns:

  • (#call)

    the original implementation on singleton



14
15
16
17
18
19
20
21
# File 'lib/mutant/require_highjack.rb', line 14

def self.call(target, callback)
  target.method(:require).tap do
    target.module_eval do
      define_method(:require, &callback)
      public :require
    end
  end
end