2014-04-04 08:38:06 -04:00
|
|
|
module Mutant
|
|
|
|
# Require highjack
|
2015-06-06 18:29:47 -04:00
|
|
|
module RequireHighjack
|
2014-04-04 08:38:06 -04:00
|
|
|
|
2015-06-06 18:29:47 -04:00
|
|
|
# Install require callback
|
2014-04-04 08:38:06 -04:00
|
|
|
#
|
2015-06-06 18:29:47 -04:00
|
|
|
# @param [Module] target
|
|
|
|
# @param [#call] callback
|
2014-04-04 08:38:06 -04:00
|
|
|
#
|
2015-06-06 18:29:47 -04:00
|
|
|
# @return [#call]
|
|
|
|
# the original implementation on singleton
|
|
|
|
def self.call(target, callback)
|
|
|
|
target.method(:require).tap do
|
|
|
|
target.module_eval do
|
|
|
|
define_method(:require, &callback)
|
|
|
|
public :require
|
2014-04-04 08:38:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end # RequireHighjack
|
|
|
|
end # Mutant
|