模块中的别名单例方法

Joe*_*ann 4 ruby module pointer-aliasing

我有一个名为的模块Setup,想要为方法添加别名.

这是它的外观,但它是如何工作的:

module Setup
  def Setup::option_set?(option)
    #...
  end
  alias :option_set? :get_information
end
Run Code Online (Sandbox Code Playgroud)

我想这与Setup::-prefix有关.该怎么办?

Eri*_*c G 6

module Setup
  class << self
    def option_set?(option)
      #...
    end
    alias :get_information :option_set? 
  end
end
Run Code Online (Sandbox Code Playgroud)