1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/lib/v8/conversion/method.rb
2012-06-12 03:51:07 -05:00

28 lines
No EOL
529 B
Ruby

class V8::Conversion
module Method
include V8::Conversion::Proc
def to_v8
(@@method_cache[self] ||= to_v8_template).GetFunction()
end
class MethodCache
def initialize
@map = {}
end
def [](method)
weakref = @map[method.to_s]
if weakref && weakref.weakref_alive?
weakref.__getobj__
end
end
def []=(method, template)
@map[method.to_s] = WeakRef.new(template)
end
end
@@method_cache = MethodCache.new
end
end