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
Instance Method Summary collapse
-
#singleton ⇒ Object
Create a singleton instance of this class.
Class Method Details
.included(klass) ⇒ Object
15 16 17 |
# File 'lib/ftw/singleton.rb', line 15 def self.included(klass) raise ArgumentError.new("In #{klass.name}, you want to use 'extend #{self.name}', not 'include ...'") end |
Instance Method Details
#singleton ⇒ Object
Create a singleton instance of this class.
20 21 22 23 |
# File 'lib/ftw/singleton.rb', line 20 def singleton @instance ||= self.new return @instance end |