lib/singleton.rb in singleton-0.1.1 vs lib/singleton.rb in singleton-0.2.0

- old
+ new

@@ -90,11 +90,11 @@ # p a == b # => true # p a.keep # => "keep this" # p a.strip # => nil # module Singleton - VERSION = "0.1.1" + VERSION = "0.2.0" # Raises a TypeError to prevent cloning. def clone raise TypeError, "can't clone instance of singleton #{self.class}" end @@ -119,15 +119,10 @@ def _load(str) instance end def instance # :nodoc: - return @singleton__instance__ if @singleton__instance__ - @singleton__mutex__.synchronize { - return @singleton__instance__ if @singleton__instance__ - @singleton__instance__ = new() - } - @singleton__instance__ + @singleton__instance__ || @singleton__mutex__.synchronize { @singleton__instance__ ||= new } end private def inherited(sub_klass)