From: Trans Date: 2006-10-18T23:50:08+09:00 Subject: Re: Mixin a module method as a class method Farrel Lifson wrote: > Is it possible to mix in a module method to become a class method? I'd > like to define the method_added method in a module and then mix it > into a class like so > module Foo > def self.method_added(method) > puts "Added #{method}" > end > end > > class Bar > include Foo > def bar > end > def baz > end > end > So that I get > Added bar > Added baz > printed out. Is there any way to do this besides making Foo a class > and subclassing Foo from it? Search ruby-talk for #class_extension. require 'facet/module/calss_extension' module Foo class_extension { def method_added(method) puts "Added #{method}" end } end T.