I have a ruby class that is using the Singleton pattern. I would like to initialize an instance variable as soon as the class is create (i.e instance is called). Where is the best place to do this?
require 'singleton'
class SingletonTest
include Singleton
@my_var # where / how should I initialize this
end
Thanks
You should do that in the constructor, i.e.
You’re guaranteed to have the constructor called before
.instancereturns.