From: Rick DeNatale Date: 2007-11-06T23:30:05+09:00 Subject: Re: Superclass of a module On 11/5/07, Todd Corenson wrote: > Does this make Foo a singleton class of Module? This would explain how > Foo could respond to super, yet have no superclass. But this would > still be strange because > > module Foo > def self.append_features(b) > super > end > end > > would make append_features a module method and yet > Module.new.respond_to?(:append_features, true) is true. For a class, > this implies that append_features would be an instance method. I take > it this works differently for modules? No, Foo is an instance of Module. module Foo def self.append_features(b) super end end The self.append_features in the def means that we are defining the method in the context of the singleton class of Foo. Try running this: class Module def provides_method(meth) instance_methods.include?(meth.to_s) ? "provides #{meth}" : "does not provide #{meth}" end end module Foo def self.append_features(b) puts "I am #{self}" puts "My class is #{self.class} which #{self.class.provides_method(:append_features)}" sing_class = class < which provides append_features -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/