MethodWatcher
Provide method_overriding callback.
Installation
Add this line to your application's Gemfile:
gem 'method_watcher'
And then execute:
$ bundle
Or install it yourself as:
$ gem install method_watcher
Usage
require 'method_watcher'
class A
include MethodWatcher
def foo
end
def
end
watch_methods :foo, :bar
unwatch_methods :bar
end
class B < A
def foo
end
end
#you will get a warning:
# => method A#foo is overridden
#you can define you own behavior when method overriding.
#in class A:
def self.method_overriding method
raise "OMG, method #{method} is overridden!!"
end
#you can also use it like ruby core methods private, protect and public
require 'method_watcher'
class A
include MethodWatcher
# if you pass no arguments, all methods below it will be watched
watch_methods
def foo
end
def foo2
end
# if you pass no arguments, it will disable watching, methods below it will not be watched
unwatch_methods
def
end
#in this example, methods foo, foo2 should be watched
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request