24 lines
501 B
Ruby
24 lines
501 B
Ruby
module Mutant
|
|
# Require highjack
|
|
module RequireHighjack
|
|
|
|
# Install require callback
|
|
#
|
|
# @param [Module] target
|
|
# @param [#call] callback
|
|
#
|
|
# @return [#call]
|
|
# the original implementation on singleton
|
|
#
|
|
# @api private
|
|
def self.call(target, callback)
|
|
target.method(:require).tap do
|
|
target.module_eval do
|
|
define_method(:require, &callback)
|
|
public :require
|
|
end
|
|
end
|
|
end
|
|
|
|
end # RequireHighjack
|
|
end # Mutant
|