| Module | FTW::Singleton |
| In: |
lib/ftw/singleton.rb
lib/ftw/singleton.rb |
A mixin that provides singleton-ness
Usage:
class Foo
extend FTW::Singleton
...
end
foo = Foo.singleton
This is invoked when you include this module. It raises an exception because you should be using ‘extend’ not ‘include’ for this module..
This is invoked when you include this module. It raises an exception because you should be using ‘extend’ not ‘include’ for this module..
Create a singleton instance of whatever class this module is extended into.
Example:
class Foo
extend FTW::Singleton
def bar
"Hello!"
end
end
p Foo.singleton.bar # == "Hello!"
Create a singleton instance of whatever class this module is extended into.
Example:
class Foo
extend FTW::Singleton
def bar
"Hello!"
end
end
p Foo.singleton.bar # == "Hello!"