class ActiveSupport::CurrentAttributes

def instance

Returns singleton instance for this class in this thread. If none exists, one is created.
def instance
  current_instances[current_instances_key] ||= new
end