Class: Rack::PerftoolsProfiler::ProfileOnce
Class Method Summary
collapse
Instance Method Summary
collapse
check_printer, #check_printer_arg
Methods inherited from Action
for_env
Constructor Details
Returns a new instance of ProfileOnce.
10
11
12
13
14
15
16
|
# File 'lib/rack/perftools_profiler/profile_once.rb', line 10
def initialize(*args)
super
request = Rack::Request.new(@env)
@times = (request.params.fetch('times') {1}).to_i
check_printer_arg
@new_env = delete_custom_params(@env)
end
|
Class Method Details
.has_special_param?(request) ⇒ Boolean
6
7
8
|
# File 'lib/rack/perftools_profiler/profile_once.rb', line 6
def self.has_special_param?(request)
request.params['profile'] != nil
end
|
Instance Method Details
#act ⇒ Object
18
19
20
21
22
|
# File 'lib/rack/perftools_profiler/profile_once.rb', line 18
def act
@profiler.profile do
@times.times { @middleware.call_app(@new_env) }
end
end
|
#delete_custom_params(env) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/rack/perftools_profiler/profile_once.rb', line 28
def delete_custom_params(env)
new_env = env.clone
params = Rack::Request.new(new_env).params
params.delete('profile')
params.delete('times')
params.delete('printer')
params.delete('ignore')
params.delete('focus')
new_env.delete('rack.request.query_string')
new_env.delete('rack.request.query_hash')
new_env['QUERY_STRING'] = build_query(params)
new_env
end
|
#response ⇒ Object
24
25
26
|
# File 'lib/rack/perftools_profiler/profile_once.rb', line 24
def response
@middleware.profiler_data_response(@profiler.data(@data_params))
end
|