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: