"Hal E. Fulton" <hal9000 / hypermetrics.com> writes:

> Q2. I found the "append_features" trick to create a class method
> using a module... but now the module instance methods don't show up
> as instance methods of the class.  Why?

You need to call 'super' to have the real 'append_features' do its
stuff:

     module MyMod
       def MyMod.append_features(someClass)
         def someClass.aaa
           puts "aaa"
         end
         super       # <<<<
       end
     end

> Q3. OK, maybe I don't "want" to bring in both class and instance
> methods. Maybe I just "think I want it." I admit I don't have an
> application in mind; I was just experimenting. Comments?

I was just experimenting. I didn't run the code. Hmmm. Sounds like a
presidential bid to me... :)

This doesn't really address your question, but you _can_ mix a
module's instance methods in as class methods if you like:

   module Yell
     def yabba
       puts "dabba do!"
     end
   end

   class Fred
     class << self
       include Yell
     end
   end

   Fred.yabba   #=>  dabba do!



> Q4. Why is it allowable to have a method definition within the
> append_features body but not a second one? A second one gives me a
> "nested method" error. I'm not understanding something pretty basic.

It works for me. I suspect you left off an 'end'.


Regards


Dave