Module: NoBrainer::Fork

Defined in:
lib/no_brainer/fork.rb

Class Method Summary collapse

Class Method Details

.hookObject



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/no_brainer/fork.rb', line 2

def self.hook
  Kernel.module_eval do
    alias_method :fork_without_nobrainer, :fork

    def fork(&block)
      # Not so safe to disconnect in the child (c.f. driver's code)
      NoBrainer.disconnect
      fork_without_nobrainer(&block)
    end

    module_function :fork
  end
end