Class: Mutant::Zombifier
- Inherits:
-
Object
- Object
- Mutant::Zombifier
- Includes:
- Adamantium::Flat
- Defined in:
- lib/mutant/zombifier.rb,
lib/mutant/zombifier/file.rb
Overview
Zombifier namespace
Defined Under Namespace
Classes: File
Constant Summary collapse
- INCLUDES =
%r{\A#{Regexp.union(includes)}(?:/.*)?\z}.freeze
Class Method Summary collapse
-
.run(logical_name, namespace) ⇒ Object
private
Perform zombification of target library.
Instance Method Summary collapse
-
#include?(logical_name) ⇒ Boolean
private
Test if logical name is subjected to zombification.
-
#initialize(namespace) ⇒ undefined
constructor
private
Initialize object.
-
#require(logical_name) ⇒ self
private
Require file in zombie namespace.
-
#run(logical_name) ⇒ undefined
private
Run zombifier.
Constructor Details
#initialize(namespace) ⇒ undefined
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.
Initialize object
28 29 30 31 32 |
# File 'lib/mutant/zombifier.rb', line 28 def initialize(namespace) @zombified = Set.new @highjack = RequireHighjack.new(Kernel, method(:require)) super(namespace) end |
Class Method Details
.run(logical_name, namespace) ⇒ Object
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.
Perform zombification of target library
41 42 43 |
# File 'lib/mutant/zombifier.rb', line 41 def self.run(logical_name, namespace) new(namespace).run(logical_name) end |
Instance Method Details
#include?(logical_name) ⇒ Boolean
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.
Test if logical name is subjected to zombification
64 65 66 |
# File 'lib/mutant/zombifier.rb', line 64 def include?(logical_name) !@zombified.include?(logical_name) && INCLUDES =~ logical_name end |
#require(logical_name) ⇒ self
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.
Require file in zombie namespace
76 77 78 79 80 81 82 83 |
# File 'lib/mutant/zombifier.rb', line 76 def require(logical_name) @highjack.original.call(logical_name) return unless include?(logical_name) @zombified << logical_name file = File.find(logical_name) file.zombify(namespace) if file self end |
#run(logical_name) ⇒ undefined
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.
Run zombifier
53 54 55 56 |
# File 'lib/mutant/zombifier.rb', line 53 def run(logical_name) @highjack.infect require(logical_name) end |