James Gray
1/5/2006 6:48:00 PM
On Jan 5, 2006, at 12:19 PM, Jonathan Leighton wrote:
> Hi,
>
> I have a singleton class, as in one that does "include Singleton". I
> want to run a few methods when the instance is created. Usually one
> would do that in initialize(), but obviously I can't do that here.
Why not? The object is still constructed:
>> require "singleton"
=> true
>> class JustOne
>> def initialize
>> puts "initialize() called"
>> end
>> include Singleton
>> end
=> JustOne
>> JustOne.instance
initialize() called
=> #<JustOne:0x32321c>
>> JustOne.instance
=> #<JustOne:0x32321c>
James Edward Gray II