Sha256: f52b8c718e17fbf72c709bc0120aa16083f05250883cd05fc5347a9b78507547

Contents?: true

Size: 723 Bytes

Versions: 9

Compression:

Stored size: 723 Bytes

Contents

module V8
  class Object
    include Enumerable
    
    def initialize(native)
      @native = native
    end
    
    def [](key)
      @native.context.open do
        To.ruby(@native.Get(key.to_s))        
      end
    end
    
    def []=(key, value)
      value.tap do
        @native.context.open do
          @native.Set(key.to_s, value)
        end
      end
    end
    
    def to_s
      @native.context.open do
        @native.ToString()
      end
    end
    
    def each
      for prop in @native.GetPropertyNames()
        yield prop, self[prop]
      end
    end
  end
end

class Object  
  def eval_js(javascript)
    V8::Context.open(:with => self) do |cxt|
      cxt.eval(javascript)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
therubyracer-0.6.3 lib/v8/object.rb
therubyracer-0.6.2 lib/v8/object.rb
therubyracer-0.6.1 lib/v8/object.rb
therubyracer-0.6.0 lib/v8/object.rb
therubyracer-0.5.5 lib/v8/object.rb
therubyracer-0.5.4 lib/v8/object.rb
therubyracer-0.5.3 lib/v8/object.rb
therubyracer-0.5.2-x86-darwin-10 lib/v8/object.rb
therubyracer-0.5.2 lib/v8/object.rb