Skip to content

Instantly share code, notes, and snippets.

@djanowski
Created February 5, 2010 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djanowski/295801 to your computer and use it in GitHub Desktop.
Save djanowski/295801 to your computer and use it in GitHub Desktop.
module Test
module Sessions
%w{get post put delete head}.each do |verb|
eval <<-EOS
def #{verb}(uri, params = {}, env = {}, &block)
inject_session(env)
super(uri, params, env, &block)
end
EOS
end
def inject_session(env)
env[:cookie] = [env[:cookie], "rack.session=#{[Marshal.dump(env.delete(:session))].pack("m*")}"].compact.join("; ") if env[:session]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment