Class: Object

Inherits:
BasicObject
Defined in:
lib/safe_eval.rb,
lib/safe_eval.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stored_exceptionObject

Returns the value of attribute stored_exception.



63
64
65
# File 'lib/safe_eval.rb', line 63

def stored_exception
  @stored_exception
end

Instance Method Details

#app_instance_eval(str, ops = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/safe_eval.rb', line 81

def app_instance_eval(str,ops={})
  TT.log("app_instance_eval #{str}") do
    #if str =~ /children\(:picks\).parent\(:players\)/
    #  4
    #else
      safe_instance_eval(unescape(str),ops)
    #end
    #instance_eval(unescape(str))
  end
end

#safe_instance_eval(str, ops = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/safe_eval.rb', line 64

def safe_instance_eval(str,ops={})
  res = nil
  level = ops[:safe] || eval_safe_level
  debug_log "going to eval #{str} at level #{level} against #{inspect}"
  Thread.new do
    $SAFE = level if level > $SAFE
    #new_str = "begin; #{str}; rescue(Exception) => e; raise e.exception(bt+e.message); end"
    res = instance_eval(str)
  end.join
  res
rescue(SecurityError) => exp
  exp = exp.exception("Eval code \"#{str}\"\n#{exp.message}")
  raise exp
end