>>>>> "C" == Christoph Rippel <crippel / primenet.com> writes:

C> module A
C> def A.s
C> end
C> end
C> module B
C> include A
C> end
C> B.singleton_methods  # now [] - want ['s']?

 You write a delegator, *warning* this is just an example not fully tested 

pigeon% cat b.rb
#!/usr/bin/ruby
module DM
   CODE = <<-'EOT'
   for method in singleton_methods
      next if method == "append_features"
      mod.module_eval <<-EOS
      def #{mod.name}.#{method}(*args, &block)
         begin
            #{name}.send(:#{method}, *args, &block)
         rescue
            $@[0,2] = nil
            raise
         end
      end
      EOS
   end
   EOT
   def DM.append_features(mod)
      mod.module_eval <<-EOS
      def #{mod.name}.append_features(mod)
         DM.append_features(mod)
         #{CODE}
      end
      EOS
   end
end
 
module A
   include DM
   def A.a(a)
      puts "A.a #{a}"
   end
end
 
module B
   def B.b
      puts "B.b"
   end
   include A
end
 
module C
   include B
   def C.c
      puts "C.c"
   end
end
 
p A.singleton_methods
p B.singleton_methods
p C.singleton_methods
pigeon% 

pigeon% b.rb
["a", "append_features"]
["a", "append_features", "b"]
["c", "b", "a", "append_features"]
pigeon% 


Guy Decoux