Skip to content

Instantly share code, notes, and snippets.

@takkkun
Created April 16, 2013 00:05
Show Gist options
  • Select an option

  • Save takkkun/5392312 to your computer and use it in GitHub Desktop.

Select an option

Save takkkun/5392312 to your computer and use it in GitHub Desktop.
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