Created
May 22, 2013 17:59
-
-
Save peteygao/5629536 to your computer and use it in GitHub Desktop.
Attempting to inheriting an instance method from a module and then outputting a class variable that was defined in the base class. However it is not currently working :(.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Awesome | |
@@troll = "ME!" | |
end | |
module MyGem | |
module Namespace | |
def trolling | |
puts @@troll | |
end | |
end | |
end | |
if defined? Awesome | |
Awesome.class_eval do | |
include MyGem::Namespace | |
end | |
end | |
Awesome.new.trolling # Test our new 'injected' instance method! | |
#=> NameError: uninitialized class variable @@troll in MyGem::Namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment