# File lib/execjs/johnson_runtime.rb, line 35 def call(properties, *args) unbox @runtime.evaluate(properties).call(*args) rescue Johnson::Error => e if syntax_error?(e) raise RuntimeError, e.message else raise ProgramError, e.message end end
# File lib/execjs/johnson_runtime.rb, line 21 def eval(source, options = {}) source = encode(source) if /\S/ =~ source unbox @runtime.evaluate("(#{source})") end rescue Johnson::Error => e if syntax_error?(e) raise RuntimeError, e.message else raise ProgramError, e.message end end
# File lib/execjs/johnson_runtime.rb, line 13 def exec(source, options = {}) source = encode(source) if /\S/ =~ source eval "(function(){#{source}})()", options end end
# File lib/execjs/johnson_runtime.rb, line 45 def unbox(value) case when function?(value) nil when string?(value) value.respond_to?(:force_encoding) ? value.force_encoding('UTF-8') : value when array?(value) value.map { |v| unbox(v) } when object?(value) value.inject({}) do |vs, (k, v)| vs[k] = unbox(v) unless function?(v) vs end else value end end
Generated with the Darkfish Rdoc Generator 2.