Skip to content

Instantly share code, notes, and snippets.

@barmstrong
Forked from markmeeus/gist:6412088
Last active August 29, 2015 14:22
Show Gist options
  • Save barmstrong/b463bc62d0caaf4dcf42 to your computer and use it in GitHub Desktop.
Save barmstrong/b463bc62d0caaf4dcf42 to your computer and use it in GitHub Desktop.
module Celluloid
class Thread < ::Thread
def []= key, value
if key_on_thread? key
thread_vars[key] = value
else
super
end
end
def [] key
if key_on_thread? key
thread_vars[key]
else
super
end
end
private
def thread_vars
@thread_vars ||= {}
end
def key_on_thread? key
key == "[mongoid]:sessions"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment