From: Dave Thomas Date: 2001-01-31T12:56:35+09:00 Subject: [ruby-talk:10156] Re: Defining class methods in a module "Nathaniel Talbott" writes: > Is this possible?: Heh, this is Ruby! > What I'm trying to do is define a method in a module that will be 'included' > (and useable) at the _class_ level. The syntax above doesn't work (I've > tried it); is there a syntax that does? Is there another alternative > implementation for this type of behavior that I'm missing? My end goal is to > add a method sort of like one of the attr* methods, and I don't want to > modify Module itself (so the behavior can be mixed in as needed). If I'm understanding what you want, how about: module Mod def Mod.append_features(klass) def klass.method puts "In method" end end end class Cl1 include Mod end class Cl2 include Mod end Cl1.method Cl2.method Any class that includes 'Mod' will get 'method' as a class method. Regards Dave