Sha256: ae6095f6de2e5bff3b98018a7d4a9146f661977db923659deb3cf9f16d9967d4

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

require "execjs/encoding"

module ExecJS
  # Abstract base class for runtimes
  class Runtime
    class Context
      include Encoding

      def initialize(runtime, source = "", options = {})
      end

      def exec(source, options = {})
        raise NotImplementedError
      end

      def eval(source, options = {})
        raise NotImplementedError
      end

      def call(properties, *args)
        raise NotImplementedError
      end
    end

    def name
      raise NotImplementedError
    end

    def context_class
      self.class::Context
    end

    def exec(source, options = {})
      context = compile("", options)

      if context.method(:exec).arity == 1
        context.exec(source)
      else
        context.exec(source, options)
      end
    end

    def eval(source, options = {})
      context = compile("", options)

      if context.method(:eval).arity == 1
        context.eval(source)
      else
        context.eval(source, options)
      end
    end

    def compile(source, options = {})
      if context_class.instance_method(:initialize).arity == 2
        context_class.new(self, source)
      else
        context_class.new(self, source, options)
      end
    end

    def deprecated?
      false
    end

    def available?
      raise NotImplementedError
    end
  end
end

Version data entries

14 entries across 14 versions & 5 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/runtime.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/execjs-2.7.0/lib/execjs/runtime.rb
arcabouco-0.2.13 vendor/bundle/gems/execjs-2.7.0/lib/execjs/runtime.rb
execjs-2.7.0 lib/execjs/runtime.rb