Sha256: 27c4a42b33e492242b2de7d1e4f13bd0bd07cb5dd9bd841bf0e885577b4b53ab

Contents?: true

Size: 837 Bytes

Versions: 1

Compression:

Stored size: 837 Bytes

Contents

# ==========================================================================
# Project:   Spade - CommonJS Runtime
# Copyright: ©2010 Strobe Inc. All rights reserved.
# License:   Licened under MIT license (see LICENSE)
# ==========================================================================

module Spade

  # Evaluator plugin for the default context.  Know how to create a new
  # isolated context for the object
  class Evaluator
    
    def initialize(ctx)
      @ctx = ctx
    end
    
    def setup(sandbox)
      if sandbox['isIsolated']
        sandbox['ctx'] = Context.new :reactor => @ctx.reactor
      end
    end
    
    def evaluate(data, sandbox, filename)
      ctx = sandbox['ctx'] || @ctx
      ctx.eval(data, filename)
    end
    
    def teardown(sandbox)
      sandbox['ctx'] = nil
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spade-0.1.1.1 lib/spade/evaluator.rb