I'm trying to create a singleton class that requires some sophisticated initialization. I've boiled my problem down to this test case:
class Dumb
attr_accessor :mything
@my_thing = 1 # this works
self.init_some_stuff # this gives undefined method
class << self
def init_some_stuff
@my_thing = 2
end
def spill_it
puts "My Thing: #{@my_thing}"
end
end
end
I can initialize simple variables, but want to call class methods to do it, and I get "undefined method". Since I intend it to be used as a singleton, a constructor would not get called. What am I missing?