Created
April 8, 2014 14:01
-
-
Save judofyr/10128699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_session | |
envs = ObjectSpace.each_object(Hash).lazy.select { |env| env.key?("rack.version") && env.key?("rack.session") } | |
before = envs.to_a | |
GC.disable | |
yield | |
after = (envs.to_a - before) | |
raise "Could not extract session" unless after.size == 1 | |
after.first['rack.session'] | |
ensure | |
GC.enable | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment