Created
February 5, 2016 11:56
-
-
Save thomd/a0b2227106be3a662f2d to your computer and use it in GitHub Desktop.
module hooks in ruby
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 Module1 | |
def self.method1 | |
puts "method1 called" | |
end | |
end | |
class Test | |
def self.method_missing(name, *args) | |
if Module1.respond_to?(name) | |
return Module1.__send__(name, *args) | |
end | |
end | |
def self.method2 | |
puts "method2 is called" | |
end | |
end | |
Test.method1 | |
Test.method2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment