-
-
Save banister/4513230 to your computer and use it in GitHub Desktop.
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
[1] pry(main)> module MyModule | |
| def stuff | |
| include Module.new { | |
| def my_method | |
| puts "bar!" | |
| end | |
| } | |
| end | |
| end | |
=> nil | |
[2] pry(main)> class MyClass | |
| extend MyModule | |
| stuff | |
| end | |
=> MyClass | |
[3] pry(main)> class MyClass | |
| def my_method | |
| puts "foo!" | |
| super | |
| end | |
| end | |
=> nil | |
[4] pry(main)> MyClass.new.my_method | |
foo! | |
bar! | |
=> nil | |
[5] pry(main)> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment