Class: ExecJS::RubyRacerRuntime::Context

### Home Classes Methods

### In Files

- lib/execjs/ruby_racer_runtime.rb

### Parent

Runtime::Context

### Methods

- ::new
- #call
- #eval
- #exec
- #unbox

### Class/Module Index

Quicksearch

- ExecJS
- ExecJS::DisabledRuntime
- ExecJS::DuktapeRuntime
- ExecJS::DuktapeRuntime::Context
- ExecJS::Encoding
- ExecJS::Error
- ExecJS::ExternalRuntime
- ExecJS::ExternalRuntime::Context
- ExecJS::ProgramError
- ExecJS::RubyRacerRuntime
- ExecJS::RubyRacerRuntime::Context
- ExecJS::RubyRhinoRuntime
- ExecJS::RubyRhinoRuntime::Context
- ExecJS::Runtime
- ExecJS::Runtime::Context
- ExecJS::RuntimeError
- ExecJS::RuntimeUnavailable
- ExecJS::Runtimes

No matching classes.

# ExecJS::RubyRacerRuntime::Context

### Public Class Methods

new(runtime, source = "") click to toggle source

    # File lib/execjs/ruby_racer_runtime.rb, line 6
    def initialize(runtime, source = "")
      source = encode(source)

      lock do
        @v8_context = ::V8::Context.new

        begin
          @v8_context.eval(source)
        rescue ::V8::JSError => e
          raise wrap_error(e)
        end
      end
    end

### Public Instance Methods

call(properties, *args) click to toggle source

    # File lib/execjs/ruby_racer_runtime.rb, line 42
    def call(properties, *args)
      lock do
        begin
          unbox @v8_context.eval(properties).call(*args)
        rescue ::V8::JSError => e
          raise wrap_error(e)
        end
      end
    end

eval(source, options = {}) click to toggle source

    # File lib/execjs/ruby_racer_runtime.rb, line 28
    def eval(source, options = {})
      source = encode(source)

      if /\S/ =~ source
        lock do
          begin
            unbox @v8_context.eval("(#{source})")
          rescue ::V8::JSError => e
            raise wrap_error(e)
          end
        end
      end
    end

exec(source, options = {}) click to toggle source

    # File lib/execjs/ruby_racer_runtime.rb, line 20
    def exec(source, options = {})
      source = encode(source)

      if /\S/ =~ source
        eval "(function(){#{source}})()", options
      end
    end

unbox(value) click to toggle source

    # File lib/execjs/ruby_racer_runtime.rb, line 52
    def unbox(value)
      case value
      when ::V8::Function
        nil
      when ::V8::Array
        value.map { |v| unbox(v) }
      when ::V8::Object
        value.inject({}) do |vs, (k, v)|
          vs[k] = unbox(v) unless v.is_a?(::V8::Function)
          vs
        end
      when String
        value.force_encoding('UTF-8')
      else
        value
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.