シングルトン動作のクラスが必要です。
シングルトンモジュールを使用することの違いは何ですか...
require 'singleton'
class X
include Singleton
def set_x(x)
@x = x
end
def test
puts @x
end
end
X::instance.set_x('hello')
X::instance.test
...そしてクラスメソッドとクラスインスタンス変数を使用していますか?
class X
def self.set_x(x)
@x = x
end
def self.test
puts @x
end
end
X::set_x('hello')
X::test