Module: Sandboxed::Modes

Defined in:
lib/sandboxed.rb

Class Method Summary collapse

Class Method Details

.ctx_only(level, ctx, args, &block) ⇒ Object



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

def ctx_only(level, ctx, args, &block)
  proc {
    $SAFE=level
    (ctx || eval("self", block.binding)).instance_exec(*args, &block)
  }.call
end

.overlay(level, ctx, args, &block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/sandboxed.rb', line 19

def overlay(level, ctx, args, &block)
  class << eval("self", block.binding)
    include ContextHolder
  end if ctx

  proc {
    $SAFE = level
    yield *args
  }.call
end