Created
February 5, 2013 02:53
-
-
Save jpterry/4711762 to your computer and use it in GitHub Desktop.
Including a module in ruby inherits nested classes. This is an example.
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
module JohnsThings | |
class AwesomeTool | |
def is_awesome? | |
true | |
end | |
end | |
end | |
class HurricaneTool | |
include JohnsThings | |
def is_awesome? | |
AwesomeTool.new.is_awesome? # This works! Even though I'm not in JohnsThings namespace | |
end | |
end | |
ht = HurricaneTool.new.is_awesome? #=> true | |
HurricaneTool::AwesomeTool #=> JohnsThings::AwesomeTool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yay Ruby!!