What is actually occurring when private/protected is stated within a Ruby class definition? They are not keywords, so that implies they must be method calls, but I cannot find where they are defined. They do not appear to be documented. Are the two different ways of declaring private/protected methods (shown below) implemented differently? (The second way is obviously a method call, but this is not so apparent in the first way.)
class Foo
private
def i_am_private; end
def so_am_i; end
end
class Foo
def i_am_private; end
def so_am_i; end
private :i_am_private, :so_am_i
end
Both are method calls. Quoting from docs:
See documentation here:
You were looking for how the
Module.privatemethod comes into existence. Here is where that happens. And here is some more information about it. You would have to read more into it, starting fromrb_define_private_methoddefined inclass.c.Hope that helps!