Last active
December 16, 2015 01:29
-
-
Save jarrettmeyer/5355188 to your computer and use it in GitHub Desktop.
Ruby mixin behavior
This file contains hidden or 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 A | |
| def do_something | |
| puts "In A" | |
| end | |
| end | |
| module B | |
| def do_something_else | |
| puts "In B" | |
| end | |
| end | |
| class MyClass | |
| include A | |
| include B | |
| def do_something | |
| puts "In MyClass" | |
| end | |
| end | |
| a = MyClass.new | |
| def a.do_something | |
| puts "in local instance" | |
| end | |
| a.do_something | |
| # => in local instance | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment