On Monday, June 25, 2012 11:24:12 AM UTC-5, koops wrote:
In the 0.11 changelog, there's a line about a new value conversion framework. Is this demonstrated or documented anywhere? I'm wondering if the "unboxing" as used in https://github.com/sstephenson/execjs/blob/master/lib/execjs/ruby_racer_runtime.rb may now be redundant.
I wouldn't say that it's redundant in that the standard v8 conversions are not sufficient for what they want which is apparently to nil out functions, but it could be written more elegantly now. i.e.
conversion = @v8_context.conversion
def conversion.to_ruby(v8_object)
v8_object.is_a?(V8::C::Function) ? nil : super
end
or in a perhaps more module manner:
module NoFunctions
def to_ruby(v8_object)
v8_object.is_a?(V8::C::Function) ? nil : super
end
end
module ForceUtf8
def to_ruby(v8_object)
super.tap do |object|
object.force_endoding('UTF-8') if object.respond_to?(:force_encoding)
end
end
end
@v8_context.conversion.extend NoFunctions
@v8_context.conversion.extend ForceUtf8
--koops