Skip to content

Instantly share code, notes, and snippets.

@peteygao
Created May 22, 2013 17:59
Show Gist options
  • Save peteygao/5629536 to your computer and use it in GitHub Desktop.
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 :(.
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