-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathex23.rb
21 lines (19 loc) · 969 Bytes
/
ex23.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
https://github.com/ileitch/hijack/blob/master/examples/rails_dispatcher.rb
# Not sure about this
ActionController::Dispatcher.class_eval do
# Not sure about this
class << self
# Method called "dispatch_with_spying" created with 3 arguments available.
def dispatch_with_spying(cgi, session_options, output)
# Send invokes a method specified and passes arguments. Env_table being the method I believe
env = cgi.__send__(:env_table)
# Prints the time with a speific format specified by 'strftime'. Also printing out two keys inside of env
puts "#{Time.now.strftime('%Y/%m/%d %H:%M:%S')} - #{env['REMOTE_ADDR']} - #{env['REQUEST_URI']}"
# We're passing 3 arguements to a new method
dispatch_without_spying(cgi, session_options, output)
end
# Basically, when using dispatch, it will refer to dispatch_without_spying and vice versa
alias_method :dispatch_without_spying, :dispatch
alias_method :dispatch, :dispatch_with_spying
end
end