Module: FTW::Singleton
- Included in:
- DNS, WebSocket::Writer
- Defined in:
- lib/ftw/singleton.rb
Overview
A mixin that provides singleton-ness
Usage:
class Foo
extend FTW::Singleton
...
end
foo = Foo.singleton
Class Method Summary collapse
-
.included(klass) ⇒ Object
This is invoked when you include this module.
Instance Method Summary collapse
-
#singleton ⇒ Object
Create a singleton instance of whatever class this module is extended into.
Class Method Details
.included(klass) ⇒ Object
This is invoked when you include this module. It raises an exception because you should be using ‘extend’ not ‘include’ for this module..
17 18 19 |
# File 'lib/ftw/singleton.rb', line 17 def self.included(klass) raise ArgumentError.new("In #{klass.name}, you want to use 'extend #{self.name}', not 'include ...'") end |