GGarramuno wrote:
>
> Ok... but color me confused. Kernel is a module which has those
> functions I could not alias. How does a module inherit functions from
> a class? Also, why does Kernel.ancestors not show this relationship?
> If I do Module.ancestors, it shows Kernel instead as one of its
> ancestors. What kind of magic is going on behind the scenes here?
>
class Object
class << self
p [:A, self, ancestors]
#-> [:A, #<Class:Object>, [Class, Module, Object, Kernel]]
alias :_constants :constants
alias :_instance_methods :instance_methods
alias :_public_instance_methods :public_instance_methods
alias :_protected_instance_methods :protected_instance_methods
alias :_private_instance_methods :private_instance_methods
end
p [:B, self, ancestors] #-> [:B, Object, [Object, Kernel]]
alias :_methods :methods
end
klass = String
p klass._constants == klass.constants
p klass._instance_methods == klass.instance_methods
p klass._public_instance_methods == klass.public_instance_methods
p klass._protected_instance_methods == klass.protected_instance_methods
p klass._private_instance_methods == klass.private_instance_methods
p klass.new._methods == klass.new.methods
#-> true
daz