[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dennou-ruby:001199] Re: [ANN] RubyDCL 1.1.0
At Mon, 20 May 2002 15:14:21 +0900,
Takeshi Horinouchi wrote:
> エリアスに有効ではないのは当然としても、udcntr の中でしか呼んで
> いないものも module_function にしてないとならないって納得がいか
> ない。__udcntr はプライベートなメソッドにしたいんだけど、どうす
> ればいいんだろう..?
とりあえずこういうのはどうでしょう?
  class Module
    def module_function_subroutine(*arg)
      arg.each do |s|
        module_function s
        private_class_method s
      end
    end
  end
  module Test
    def hello
      p hello_str
    end
    module_function(:hello)
    def hello_str
      "HELLO"
    end
    module_function_subroutine(:hello_str)
  end
  begin
    Test.hello     #=> "HELLO"
    Test.hello_str
  rescue Exception
    p $!  #<NoMethodError: private method `hello_str' called for Test:Module>
  end
-- Gotoken