Class: MiniRacer::Context
- Inherits:
-
Object
- Object
- MiniRacer::Context
- Defined in:
- lib/mini_racer.rb
Overview
eval is defined in the C class
Defined Under Namespace
Classes: ExternalFunction
Instance Method Summary collapse
- #attach(name, callback) ⇒ Object
- #eval(str) ⇒ Object
-
#initialize(options = nil) ⇒ Context
constructor
A new instance of Context.
- #load(filename) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Context
Returns a new instance of Context.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/mini_racer.rb', line 77 def initialize( = nil) @functions = {} @lock = Mutex.new @timeout = nil @current_exception = nil if @timeout = [:timeout] end end |
Instance Method Details
#attach(name, callback) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/mini_racer.rb', line 100 def attach(name, callback) @lock.synchronize do external = ExternalFunction.new(name, callback, self) @functions["#{name}"] = external end end |
#eval(str) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/mini_racer.rb', line 93 def eval(str) @lock.synchronize do @current_exception = nil eval_unsafe(str) end end |
#load(filename) ⇒ Object
88 89 90 91 |
# File 'lib/mini_racer.rb', line 88 def load(filename) # TODO do this native cause no need to allocate VALUE here eval(File.read(filename)) end |