At Thu, 12 Sep 2002 17:59:50 +0900, Overnight wrote: > Suppose that module M publishes an 'm' function, which is implemented by > 'm1', which in turn uses 'm2'. > > Having exluded the 'module_function' approach: > > > module M > def m2 > puts "In M2" > end > > def m1 > m2 > end > > def m > m1 > end > module_function :m > end > > since it won't work: > > M.m -> mod3.rb:11:in `m': undefined local variable or method `m1' for > M:Module (NameError) another solution: class Module def module_function_subroutine(*names) for m in names module_function m private_class_method m end end end module M def m2() puts "m2" end def m1() m2 end def m() m1 end module_function :m module_function_subroutine :m1, :m2 end M.m M.m1 #=> NameError or NoMethodError M.m2 #=> NameError or NoMethodError -- Gotoken