Module: Rufus
- Defined in:
- lib/rufus/eval.rb
Class Method Summary collapse
-
.eval_safely(code, safe_level, binding = nil) ⇒ Object
Runs an eval() call at a certain safety level.
-
.instance_eval_safely(instance, code, safe_level) ⇒ Object
Runs some code within an instance’s realm at a certain safety level.
Class Method Details
.eval_safely(code, safe_level, binding = nil) ⇒ Object
Runs an eval() call at a certain safety level.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rufus/eval.rb', line 95 def Rufus.eval_safely (code, safe_level, binding=nil) return eval(code, binding) if on_jruby? code.untaint binding.taint r = nil Thread.new do $SAFE = safe_level r = eval code, binding end.join raise "cannot TAMPER with JRUBY_VERSION" if on_jruby? r end |
.instance_eval_safely(instance, code, safe_level) ⇒ Object
Runs some code within an instance’s realm at a certain safety level.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rufus/eval.rb', line 74 def Rufus.instance_eval_safely (instance, code, safe_level) return instance.instance_eval(code) if on_jruby? code.untaint r = nil Thread.new do $SAFE = safe_level r = instance.instance_eval(code) end.join raise "cannot TAMPER with JRUBY_VERSION" if on_jruby? r end |