Created
April 16, 2013 00:05
-
-
Save takkkun/5392312 to your computer and use it in GitHub Desktop.
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
| class Neko | |
| %w(public protected private).each do |method_name| | |
| original_method = method(method_name) | |
| define_singleton_method(method_name) do |*args, &block| | |
| puts "Called: #{method_name}" | |
| original_method[*args, &block] | |
| end | |
| end | |
| def public_method; end | |
| private | |
| def private_method; end | |
| protected | |
| def protected_method; end | |
| end | |
| puts Neko.new.public_methods.include?(:public_method) | |
| puts Neko.new.protected_methods.include?(:protected_method) | |
| puts Neko.new.private_methods.include?(:private_method) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment