From 65acfdbe6adaa6106c53d187d46b9a9bc89c59b0 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Mon, 11 Jun 2012 05:14:15 -0500 Subject: [PATCH] maintain referential integrity for embedded procs --- lib/v8/conversion/proc.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/v8/conversion/proc.rb b/lib/v8/conversion/proc.rb index 00ab947..2f672ae 100644 --- a/lib/v8/conversion/proc.rb +++ b/lib/v8/conversion/proc.rb @@ -1,9 +1,16 @@ class V8::Conversion module Proc + def to_v8 - template = V8::C::FunctionTemplate::New() - template.SetCallHandler(InvocationHandler.new, V8::C::External::New(self)) - return template.GetFunction() + return v8_template.GetFunction() + end + + def v8_template + unless @v8_template + @v8_template = V8::C::FunctionTemplate::New() + @v8_template.SetCallHandler(InvocationHandler.new, V8::C::External::New(self)) + end + return @v8_template end class InvocationHandler