Module: FakeFS::Kernel

Defined in:
lib/fakefs/kernel.rb

Overview

Kernel Module

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.captivesObject

Returns the value of attribute captives


7
8
9
# File 'lib/fakefs/kernel.rb', line 7

def captives
  @captives
end

Class Method Details

.hijack!Object


10
11
12
13
14
15
16
# File 'lib/fakefs/kernel.rb', line 10

def self.hijack!
  captives[:hijacked].each do |name, prc|
    ::Kernel.send(:remove_method, name.to_sym)
    ::Kernel.send(:define_method, name.to_sym, &prc)
    ::Kernel.send(:private, name.to_sym)
  end
end

.unhijack!Object


18
19
20
21
22
23
24
25
26
# File 'lib/fakefs/kernel.rb', line 18

def self.unhijack!
  captives[:original].each do |name, _prc|
    ::Kernel.send(:remove_method, name.to_sym)
    ::Kernel.send(:define_method, name.to_sym, proc do |*args, &block|
      ::FakeFS::Kernel.captives[:original][name].call(*args, &block)
    end)
    ::Kernel.send(:private, name.to_sym)
  end
end