From 9ca6bb737426a20b9ae08d24190cdd6d3bb21e16 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Wed, 2 Dec 2009 00:46:51 -0600 Subject: [PATCH] add docs for the options to open --- lib/rhino/context.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/rhino/context.rb b/lib/rhino/context.rb index 7ed9413..584aee1 100644 --- a/lib/rhino/context.rb +++ b/lib/rhino/context.rb @@ -45,6 +45,10 @@ module Rhino end + # Create a new javascript environment for executing javascript and ruby code. + # * :sealed - if this is true, then the standard objects such as Object, Function, Array will not be able to be modified + # * :with - use this ruby object as the root scope for all javascript that is evaluated + # * :java - if true, java packages will be accessible from within javascript def initialize(options = {}) #:nodoc: ContextFactory.new.call do |native| @native = native @@ -92,10 +96,6 @@ module Rhino end if open? end - def open? - @native == J::Context.getCurrentContext() || (raise ContextError, "context must be open") - end - # Read the contents of filename and evaluate it as javascript. Returns the result of evaluating the # javascript. e.g. # @@ -117,6 +117,8 @@ module Rhino @native.factory.instruction_limit = limit end + # Enter this context for operations. Some methods such as eval() will + # fail unless this context is open def open begin @native.factory.enterContext(@native) @@ -126,6 +128,13 @@ module Rhino end if block_given? end + private + + def open? + @native == J::Context.getCurrentContext() || (raise ContextError, "context must be open") + end + + end class IOReader < Java::JavaIo::Reader #:nodoc: