On Tue, 12 Dec 2006, Trans wrote:

> speaking of this "export" method, how does one do that for a whole
> module? ie. adding one module_finction module to another.
>
>  module X
>    module_function
>    def f; "f"; end
>  end
>
>  module Q
>    module_function
>    include X
>    extend X
>  end
>
> but that doesn't work b/c
>
>  Q.f #=>  ERROR: private method `f' called for Q:Module
>
> t.


     harp:~ > cat a.rb
     module X
       module_function  # side effect -> instance 'f' made private
       def f; "f"; end
       public :f
     # ^^^^^^ ^^
     # ^^^^^^ ^^
     # ^^^^^^ ^^
     end

     module Q
       module_function
       include X
       extend X
     end

     p Q.f

     p Object.new.instance_eval{ extend Q and self }.f

     include Q
     p f


     harp:~ > ruby a.rb
     "f"
     "f"
     "f"


regards.

-a
-- 
if you want others to be happy, practice compassion.
if you want to be happy, practice compassion.  -- the dalai lama