Module: Singleton
- Defined in:
- lib/opal/singleton.rb
Overview
–
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
++
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/opal/singleton.rb', line 20 def self.included(klass) super class << klass def new raise ArgumentError, "you can't call #new on a Singleton" if @instance @instance = super end undef_method :allocate def instance @instance ||= new() end end end |
Instance Method Details
#clone ⇒ Object
12 13 14 |
# File 'lib/opal/singleton.rb', line 12 def clone raise TypeError, "can't clone instance of singleton #{self.class}" end |
#dup ⇒ Object
16 17 18 |
# File 'lib/opal/singleton.rb', line 16 def dup raise TypeError, "can't dup instance of singleton #{self.class}" end |