123456789_123456789_123456789_123456789_123456789_

Module: Singleton::SingletonClassProperties

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Defined in: lib/singleton.rb

Class Method Summary

Instance Method Summary

Class Method Details

.extended(c)

[ GitHub ]

  
# File 'lib/singleton.rb', line 157

def self.extended(c)
  # extending an object with Singleton is a bad idea
  c.singleton_class.send(:undef_method, :extend_object)
end

.included(c)

[ GitHub ]

  
# File 'lib/singleton.rb', line 152

def self.included(c)
  # extending an object with Singleton is a bad idea
  c.undef_method :extend_object
end

Instance Method Details

#__init__(klass)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/singleton.rb', line 162

def __init__(klass) # :nodoc:
  klass.instance_eval {
    set_instance(nil)
    set_mutex(Thread::Mutex.new)
  }
  klass
end

#append_features(mod) (private)

[ GitHub ]

  
# File 'lib/singleton.rb', line 172

def append_features(mod)
  #  help out people counting on transitive mixins
  unless mod.instance_of?(Class)
    raise TypeError, "Inclusion of the OO-Singleton module in module #{mod}"
  end
  super
end

#included(klass) (private)

[ GitHub ]

  
# File 'lib/singleton.rb', line 180

def included(klass)
  super
  klass.private_class_method :new, :allocate
  klass.extend module_with_class_methods
  Singleton.__init__(klass)
end