"Christoph" <swap(news_chr)@gmx.net> schrieb im Newsbeitrag
news:blgajs$30q6$1 / ulysses.news.tiscali.de...
> "Nathaniel Talbott"  wrote:
> ...
> >   module M
> >     def self.append_features(klass)
> >       class << klass
> >         def class_method
> >           p "class_method"
> >         end
> >       end
> >       super
> >     end
>
> Actually the append_feature + super trick is somewhat
> outdated in 1.8.0  - use  #included instead.
>
> ---
> module M
> end
>
> class << M
>     module ClassMethods # this avoids name pollution
>         def class_method1
>            p "class_method"
>         end
>         def class_method2
>            p "class_method2"
>         end
>     end
>     def included(mod)
>         if mod.is_a? Class
>             mod.extend ClassMethods
>         else
>             # maybe raise an exception ?
>             raise "bla ..."
>         end
>     end
> end
>
> class C
>      include M
>  end
> ---

This looks a bit complicated to me.  IMHO you achieve the same with this
much shorter version_

module M
    def class_method1
       p "class_method"
    end
    def class_method2
       p "class_method2"
    end
end

class C
  extend M
end


alternatively:

class C
  class << self
     include M
  end
end

Regards

    robert