List of callback methods
If you ever wondered about the power of method\_missing
you were
still missing a lot. Ruby has a whole bunch of meta callback methods. Since I
always forget some of them, I will try to collect all of them in the following
list, so everybody may benefit. If I missed something, please give me a
hint.
Class | Name | corresponds to |
---|---|---|
Module | included | |
Module | extended | |
Module | append_feature | include? |
Module | const_missing | const_defined? |
Module | method_added | |
Module | method_removed | |
Module | method_undefined | |
Class | inherited | |
Object | singleton_method_added | |
Object | singleton_method_removed | |
Object | singleton_method_undefined | |
Kernel | at_exit | |
Kernel | method_missing | respond_to? |
Kernel | set_trace_func | |
Kernel | trace_var | |
Kernel | untrace_var | |
ObjectSpace | each_object |
Most of this list is taken from this discussion on ruby-talk.
And of course there are all these nice collections, you may request.
Class | Name | include super |
---|---|---|
Module | ancestors | |
Module | constants | |
Module | included_modules | |
Module | instance_methods | true |
Module | private_instance_methods | true |
Module | protected_instance_methods | true |
Module | public_instance_methods | true |
Module | class_variables | |
Class | superclass | |
Object | methods | |
Object | private_methods | true |
Object | protected_methods | true |
Object | public_methods | true |
Object | singleton_methods | true |
Object | instance_variables |
Please note, that most of the \*methods
have a parameter, which
allows you to exclude inherited properties from the answer (as listed in the
table).
Every ambitous Ruby programmer should have a look at these and come back each one or two months. These methods will allow you some shortcuts and more elegant solutions. As well, make sure, that these still work, after you introduced changes on the meta-level.

My name is Gregor Schmidt. I am a freelance Ruby and JavaScript web developer based in Berlin, Germany. I do Ruby and Rails since 2005, JavaScript since 2006. I wrote my first Redmine plugin in 2007.
I mainly work with Rails, Backbone, and Bootstrap, but I am also good at picking up new frameworks, since I will probably know most of their concepts from other projects.
If your interested in more of my previous work have a look at my portfolio. I have also published my rates for everybody to see. I would love to hear, how I may help you.