Created
February 5, 2010 13:59
-
-
Save djanowski/295801 to your computer and use it in GitHub Desktop.
This file contains 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
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