Skip to content

Instantly share code, notes, and snippets.

@jwaldrip
Last active December 11, 2015 21:19
Show Gist options
  • Save jwaldrip/4661893 to your computer and use it in GitHub Desktop.
Save jwaldrip/4661893 to your computer and use it in GitHub Desktop.
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