-
-
Save wycats/d16b1c64b9f88169ad1c to your computer and use it in GitHub Desktop.
Revisions
-
paulodiniz created this gist
Oct 7, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ module Mst def self.included(base) base.extend(ClassMethods) end module ClassMethods def before(method_name) m = instance_method(method_name) define_method method_name do |*args, &block| yield m.bind(self).(*args, &block) end end end end class Foo include Mst def test puts "test" end before :test do puts "before" end end Foo.new.test