Class: Safemode::Box
Instance Method Summary collapse
- #eval(code, assigns = {}, locals = {}, &block) ⇒ Object
-
#initialize(delegate = nil, delegate_methods = [], filename = nil, line = nil) ⇒ Box
constructor
A new instance of Box.
- #output ⇒ Object
Constructor Details
#initialize(delegate = nil, delegate_methods = [], filename = nil, line = nil) ⇒ Box
Returns a new instance of Box.
42 43 44 45 46 |
# File 'lib/safemode.rb', line 42 def initialize(delegate = nil, delegate_methods = [], filename = nil, line = nil) @scope = Scope.new(delegate, delegate_methods) @filename = filename @line = line end |
Instance Method Details
#eval(code, assigns = {}, locals = {}, &block) ⇒ Object
48 49 50 51 52 |
# File 'lib/safemode.rb', line 48 def eval(code, assigns = {}, locals = {}, &block) code = Parser.jail(code) binding = @scope.bind(assigns, locals, &block) result = Kernel.eval(code, binding, @filename || __FILE__, @line || __LINE__) end |
#output ⇒ Object
54 55 56 |
# File 'lib/safemode.rb', line 54 def output @scope.output end |