class V8::Portal
def v8(value)
def v8(value) case value when V8::Object value.instance_eval {@native} when String C::String::New(value) when Symbol C::String::NewSymbol(value.to_s) when Proc,Method,UnboundMethod @proxies.rb2js(value) do @templates.to_function(value).function end when ::Array C::Array::New(value.length).tap do |a| value.each_with_index do |item, i| a.Set(i, v8(item)) end end when ::Hash C::Object::New().tap do |o| value.each do |key, val| o.Set(v8(key), v8(val)) end end when ::Time C::Date::New(value.to_f * 1000) when ::Class @proxies.rb2js(value) do constructor = @templates.to_constructor(value) constructor.exposed = true constructor.function end when nil,Numeric,TrueClass,FalseClass, C::Value value else @proxies.rb2js(value) do @templates.to_constructor(value.class).allocate(value) end end end