# singleton — a port of Ruby's stdlib Singleton mixin, bundled into rubylang and
# loaded by `require "singleton"`. `include Singleton` gives a class a single,
# lazily-created instance reachable through `.instance` (Rails' Mime types use it).
# When mixed in, the including class gains the `instance` class method.
klass.extend(SingletonClassMethods)
end
# The one instance, created on first access and memoized on the class.
@singleton_instance ||= new
end
# A subclass of a singleton is itself a singleton.
super
sub.instance_variable_set(:@singleton_instance, nil)
end
end
# A singleton instance cannot be copied — both return self is not correct, so
# Ruby raises; mirror that.
raise TypeError,
end
raise TypeError,
end
end