free_mutant/lib/mutant/require_highjack.rb
Markus Schirp c56ecdb51a Reduce zombifier
* And add a full specification
2015-06-13 04:04:15 +00:00

25 lines
507 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