From: ara.t.howard@... Date: 2006-06-16T01:10:53+09:00 Subject: Re: Why the lack of mixing-in support for Class methods? On Fri, 16 Jun 2006, Daniel Schierbeck wrote: > #class_extension is now private, the magic has been moved to > #append_features, and #class_extension has been undefined in Class, per T's > request. > > class Module > alias_method :__append_features__, :append_features > > def class_extension(&block) > @class_extension ||= Module.new do > def self.append_features(mod) > __append_features__(mod) > end > end > @class_extension.module_eval(&block) if block_given? > @class_extension > end > > private :class_extension > > def append_features(mod) > __append_features__(mod) > mod.extend(class_extension) > if mod.instance_of? Module > mod.send(:class_extension).send(:include, class_extension) > end > end > end > > class Class > undef_method :class_extension > end > > #send must of course be replaced with #funcall in 1.9 -- has there been any > progress with the naming of that? I checked the archives, but couldn't find > anything never than August '05... it sounds like a "fun call", if you know > what I mean... hopefully you don't. > > > Daniel hi daniel- is this by design? harp:~ > cat b.rb require 'class_extension' module M class_extension{ attr_accessor 'a' } end M.a # exception! harp:~ > ruby b.rb b.rb:6: undefined method `a' for M:Module (NoMethodError) i lost track of whether the module should respond to this or not... (the thread is looooong). regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama