module ActiveSupport::PerThreadRegistry

def method_missing(name, *args, &block) # :nodoc:

:nodoc:
def method_missing(name, *args, &block) # :nodoc:
  # Caches the method definition as a singleton method of the receiver.
  define_singleton_method(name) do |*a, &b|
    per_thread_registry_instance.public_send(name, *a, &b)
  end
  send(name, *args, &block)
end

def per_thread_registry_instance

def per_thread_registry_instance
  Thread.current[name] ||= new
end