Class: Spade::Evaluator
- Inherits:
-
Object
- Object
- Spade::Evaluator
- Defined in:
- lib/spade/evaluator.rb
Overview
Evaluator plugin for the default context. Know how to create a new isolated context for the object
Instance Method Summary collapse
- #evaluate(data, sandbox, filename) ⇒ Object
-
#initialize(ctx) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #setup(sandbox) ⇒ Object
- #teardown(sandbox) ⇒ Object
Constructor Details
#initialize(ctx) ⇒ Evaluator
Returns a new instance of Evaluator.
13 14 15 |
# File 'lib/spade/evaluator.rb', line 13 def initialize(ctx) @ctx = ctx end |
Instance Method Details
#evaluate(data, sandbox, filename) ⇒ Object
23 24 25 26 |
# File 'lib/spade/evaluator.rb', line 23 def evaluate(data, sandbox, filename) ctx = sandbox['ctx'] || @ctx ctx.eval(data, filename) end |
#setup(sandbox) ⇒ Object
17 18 19 20 21 |
# File 'lib/spade/evaluator.rb', line 17 def setup(sandbox) if sandbox['isIsolated'] sandbox['ctx'] = Context.new :reactor => @ctx.reactor end end |
#teardown(sandbox) ⇒ Object
28 29 30 |
# File 'lib/spade/evaluator.rb', line 28 def teardown(sandbox) sandbox['ctx'] = nil end |