Skip to content

Commit

Permalink
silenced "already initialized constant" warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
flori committed Sep 17, 2010
1 parent db3dc79 commit 2c0f8d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/json/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def deep_const_get(path) # :nodoc:

# 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
Expand Down Expand Up @@ -77,6 +78,8 @@ def generator=(generator) # :nodoc:
:object_nl => "\n",
:array_nl => "\n"
)
ensure
$VERBOSE = old
end

# Returns the JSON generator modul, that is used by JSON. This might be
Expand Down
2 changes: 1 addition & 1 deletion lib/json/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ module Ext
JSON.generator = Generator
end

JSON_LOADED = true
JSON_LOADED = true unless const_defined?(:JSON_LOADED)
end
2 changes: 1 addition & 1 deletion lib/json/pure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ module Pure
JSON.generator = Generator
end

JSON_LOADED = true
JSON_LOADED = true unless const_defined?(:JSON_LOADED)
end

4 comments on commit 2c0f8d2

@millisami
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this patch merged?

@JonasNielsen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, so annoying with the warnings!

@parndt
Copy link

@parndt parndt commented on 2c0f8d2 Oct 12, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a new minor release (ala 1.4.7) with this patched please?

@coffeencoke
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes please

Please sign in to comment.