Module: Sensu::Sandbox

Defined in:
lib/sensu/sandbox.rb

Class Method Summary collapse

Class Method Details

.eval(expression, value = nil) ⇒ Object

Evaluate a Ruby expression within the context of a simple “sandbox”, a Proc in a module method. As of Ruby 2.3.0, ‘$SAFE` no longer supports levels > 1, so its use has been removed from this method. A single value is provided to the “sandbox”.

Parameters:

  • expression (String)

    to be evaluated.

  • value (Object) (defaults to: nil)

    to provide the “sandbox” with.

Returns:

  • (Object)


12
13
14
15
16
17
# File 'lib/sensu/sandbox.rb', line 12

def self.eval(expression, value=nil)
  result = Proc.new do
    Kernel.eval(expression)
  end
  result.call
end