Class: MiniRacer::Snapshot
- Inherits:
-
Object
- Object
- MiniRacer::Snapshot
- Defined in:
- lib/mini_racer.rb
Overview
‘size` and `warmup!` public methods are defined in the C class
Instance Method Summary collapse
-
#initialize(str = '') ⇒ Snapshot
constructor
A new instance of Snapshot.
- #warmup!(src) ⇒ Object
Constructor Details
#initialize(str = '') ⇒ Snapshot
Returns a new instance of Snapshot.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/mini_racer.rb', line 317 def initialize(str = '') # ensure it first can load begin ctx = MiniRacer::Context.new ctx.eval(str) rescue MiniRacer::RuntimeError => e raise MiniRacer::SnapshotError.new, e., e.backtrace end @source = str # defined in the C class load(str) end |
Instance Method Details
#warmup!(src) ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/mini_racer.rb', line 332 def warmup!(src) # we have to do something here # we are bloating memory a bit but it is more correct # than hitting an exception when attempty to compile invalid source begin ctx = MiniRacer::Context.new ctx.eval(@source) ctx.eval(src) rescue MiniRacer::RuntimeError => e raise MiniRacer::SnapshotError.new, e., e.backtrace end warmup_unsafe!(src) end |