From: Ittay Dror Date: 2008-12-08T16:48:05+09:00 Subject: Re: include module in module Ittay Dror wrote: > Hi, > > > I have a situation like this: > > module M > > .... > > end > > > class C1 > > include M > > ... > > end > > > class C2 > > include M > > ... > > end > > > Now I want to add methods to C1 and C2 and whatever other class > includes M. > > > My first approach was: > > module S > > .... > > end > > > module M > > include S > > end > > > But this doesn't work (meaning whatever methods I have in S are > undefined for instances of C1, C2). > > > So, how can I do that? I think I solved it: module S def self.included(other) methods = instance_methods(false) other.module_eval do methods.each do |name| name = name.to_sym base.send :define_method, name, instance_method(name) end end end end Ittay > > > Thanks, > > Ittay > > -- -- Ittay Dror