-
-
Save saturnflyer/fead5b9d160286b7995f4edac2e1ea45 to your computer and use it in GitHub Desktop.
example of prepended class methods
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
class Foo | |
def self.say | |
p "hello from Foo" | |
end | |
end | |
module Bar | |
def say | |
super | |
p "hello from Bar" | |
end | |
end | |
Foo.say # => "hello from Foo" | |
Foo.singleton_class.prepend Bar | |
Foo.say # => "hello from Foo"\"hello from Bar" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment