Class: Gemlings::Sandbox::BoxExecutor

Inherits:
ForkExecutor show all
Defined in:
lib/gemlings/sandbox.rb

Overview

Ruby 4.0+: Fork with Ruby::Box namespace isolation. Agent code runs in a separate process AND a separate namespace, so monkey-patches, constants, and class variables can't leak into the host.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Executor

inherited

Class Method Details

.available? ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/gemlings/sandbox.rb', line 75

def self.available?
  super && defined?(Ruby::Box) && Ruby::Box.enabled?
end

Instance Method Details

#call(timeout, &block) ⇒ Object



79
80
81
82
83
84
# File 'lib/gemlings/sandbox.rb', line 79

def call(timeout, &block)
  super(timeout) do
    box = Ruby::Box.new
    block.call(box)
  end
end