# File lib/facet/multiton.rb, line 121 def selfself..append_featuresappend_features(klass) def klass.new(*args, &block) # if the class defined 'multiton_id' we use this as the key # otherwise we simply use the argument list. k = (respond_to?(MULTITON_ID_HOOK) ? send(MULTITON_ID_HOOK, *args, &block) : args) unless (obj = (POOLS[self] ||= {})[k]) begin critical = Thread.critical Thread.critical = true if self.respond_to?(MULTITON_NEW_HOOK) obj = (POOLS[self][k] = self.send(MULTITON_NEW_HOOK, *args, &block)) else obj = super end ensure Thread.critical = critical # restore state end end return obj end end