On Mar 9, 2011, at 14:34 , 7stud -- wrote:

> Roger Pack wrote in post #986564:
>> Hello all.
>>=20
>> Noticed this behavior:
>>=20
>>>> require 'singleton'
>> =3D> true
>>>> class A; include Singleton; end
>> =3D> A
>>>> A.instance
>> =3D> #<A:0x3703c38>
>=20
> I looked through the ruby docs and neither Object, Module, Class, nor=20=

> Singelton have a method named 'instance'.  Where does that come from?

9998 % ri Singleton
=3D Singleton

(from ruby core)
=
--------------------------------------------------------------------------=
----
The Singleton module implements the Singleton pattern.

Usage:
       class Klass
          include Singleton
          # ...
       end

* this ensures that only one instance of Klass lets call it ``the =
instance''
  can be created.

  a,b  =3D Klass.instance, Klass.instance a =3D=3D b   # =3D> true a.new =
   #=20
  NoMethodError - new is private ...

* ``The instance'' is created at instantiation time, in other words the =
first
  call of Klass.instance(), thus

          class OtherKlass
            include Singleton
            # ...
...=