Skip to content

Instantly share code, notes, and snippets.

@thomd
Created February 5, 2016 11:56
Show Gist options
  • Save thomd/a0b2227106be3a662f2d to your computer and use it in GitHub Desktop.
Save thomd/a0b2227106be3a662f2d to your computer and use it in GitHub Desktop.
module hooks in ruby
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