Last active
February 1, 2016 18:59
-
-
Save tsevdos/7d5f4e2c9b592cb7d0d2 to your computer and use it in GitHub Desktop.
Extending Class methods with Module Mixins
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 | |
module Findable | |
def find_by_name(name) | |
# find something | |
end | |
end | |
# Class | |
class Klass | |
# class stuff | |
class << self | |
include Findable | |
end | |
end |
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
Klass.find_by_name('John') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment