Skip to content

Instantly share code, notes, and snippets.

@hawx
Created July 26, 2010 16:16
Show Gist options
  • Save hawx/490778 to your computer and use it in GitHub Desktop.
Save hawx/490778 to your computer and use it in GitHub Desktop.
This is how I would maybe work around the problem of scoping monkey patches. Which should be coming in Ruby 2.0
module Test
class String < ::String; end
p String.new("Test::String").class
#=> Test::String
p ::String.new("::String").class
#=> String
p "::String".class
#=> String -> Would be better as Test::String
end
p Test::String.new("Test::String").class
#=> Test::String
p String.new("::String").class
#=> String
p "::String".class
#=> String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment