Henrik Schmidt wrote: > Wow, public, private and protected are actually method call. I wonder > how they implemented that. Now I HAVE to get the source code. :) See if the following helps: code in classes isn't compiled, it is executed. Defining a function is a discrete step that runs (and returns nil), and that you can listen for. class Foo def self.method_added( name ) puts "#{self}##{name} just added; it is #{@priv ? 'private' : 'public'}" end def self.private super @priv = true end def self.public super @priv = false end puts "About to define foo" def foo; end puts "About to define bar" p def bar; end private puts "About to define secret_sauce" def secret_sauce; end end #=> About to define foo #=> Foo#foo just added; it is public #=> About to define bar #=> Foo#bar just added; it is public #=> nil #=> About to define secret_sauce #=> Foo#secret_sauce just added; it is private