class ActiveSupport::CurrentAttributes

def instance

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