Class: Spade::Compiler
- Inherits:
-
Object
- Object
- Spade::Compiler
- Defined in:
- lib/spade/compiler.rb
Overview
Compiler plugin for the default context. Know how to create a new isolated context for the object
Instance Method Summary collapse
- #compile(data, sandbox, filename) ⇒ Object
-
#initialize(ctx) ⇒ Compiler
constructor
A new instance of Compiler.
- #setup(sandbox) ⇒ Object
- #teardown(sandbox) ⇒ Object
Constructor Details
#initialize(ctx) ⇒ Compiler
Returns a new instance of Compiler.
13 14 15 |
# File 'lib/spade/compiler.rb', line 13 def initialize(ctx) @ctx = ctx end |
Instance Method Details
#compile(data, sandbox, filename) ⇒ Object
23 24 25 26 |
# File 'lib/spade/compiler.rb', line 23 def compile(data, sandbox, filename) ctx = sandbox['ctx'] || @ctx ctx.eval("(#{data})", filename) end |
#setup(sandbox) ⇒ Object
17 18 19 20 21 |
# File 'lib/spade/compiler.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/compiler.rb', line 28 def teardown(sandbox) sandbox['ctx'] = nil end |