summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/json/common.rb3
-rw-r--r--lib/json/ext.rb2
-rw-r--r--lib/json/pure.rb2
3 files changed, 5 insertions, 2 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb
index 1c91672..d5444b9 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -49,6 +49,7 @@ module JSON
# Set the module _generator_ to be used by JSON.
def generator=(generator) # :nodoc:
+ old, $VERBOSE = $VERBOSE, nil
@generator = generator
generator_methods = generator::GeneratorMethods
for const in generator_methods.constants
@@ -77,6 +78,8 @@ module JSON
:object_nl => "\n",
:array_nl => "\n"
)
+ ensure
+ $VERBOSE = old
end
# Returns the JSON generator modul, that is used by JSON. This might be
diff --git a/lib/json/ext.rb b/lib/json/ext.rb
index a6b353d..a5e3148 100644
--- a/lib/json/ext.rb
+++ b/lib/json/ext.rb
@@ -11,5 +11,5 @@ module JSON
JSON.generator = Generator
end
- JSON_LOADED = true
+ JSON_LOADED = true unless const_defined?(:JSON_LOADED)
end
diff --git a/lib/json/pure.rb b/lib/json/pure.rb
index 1848f03..08efa83 100644
--- a/lib/json/pure.rb
+++ b/lib/json/pure.rb
@@ -73,5 +73,5 @@ module JSON
JSON.generator = Generator
end
- JSON_LOADED = true
+ JSON_LOADED = true unless const_defined?(:JSON_LOADED)
end