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

28 lines
529 B
Ruby
Raw Normal View History

2012-06-11 08:14:00 -04:00
class V8::Conversion
module Method
include V8::Conversion::Proc
def to_v8
(@@method_cache[self] ||= to_v8_template).GetFunction()
2012-06-11 08:14:00 -04:00
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