Last active
December 11, 2015 21:19
-
-
Save jwaldrip/4661893 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
class ApplicationController < ActionController::Base | |
def session | |
@session ||= SessionHijacker.new(super, request) | |
end | |
def session=(session) | |
"------ SESSION WAS REPLACED!!!" | |
super(session) | |
end | |
class SessionHijacker | |
def initialize(session, request) | |
puts colorize, 34 do | |
[ | |
"\n\nSession Initialized!", | |
" session_id: #{request.session_options[:id].inspect}\n\n" | |
].join("\n") | |
end | |
@session = session | |
end | |
def __colorize(color_code, &block) | |
"\e[#{color_code}m" + block.call + "\e[0m" | |
end | |
def method_missing(m, *args, &block) | |
return_val = @session.send(m, *args, &block) | |
puts __colorize 35 do | |
[ | |
"Session Called ", | |
" #{m}(#{args.map(&:inspect).join(', ')})", | |
" Returned: #{return_val.inspect}" | |
].join("\n") + "\n\n" | |
end | |
return_val | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment