Class: Rack::ProfileOnce
- Includes:
- Utils
- Defined in:
- lib/rack/contrib/perftools_profiler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #act ⇒ Object
- #delete_custom_params(env) ⇒ Object
-
#initialize(*args) ⇒ ProfileOnce
constructor
A new instance of ProfileOnce.
- #response ⇒ Object
Methods inherited from Action
Constructor Details
#initialize(*args) ⇒ ProfileOnce
Returns a new instance of ProfileOnce.
328 329 330 331 332 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 328 def initialize(*args) super @times = (Request.new(@env).params.fetch('times') {1}).to_i @new_env = delete_custom_params(@env) end |
Class Method Details
.has_special_param?(request) ⇒ Boolean
324 325 326 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 324 def self.has_special_param?(request) request.params['profile'] != nil end |
Instance Method Details
#act ⇒ Object
334 335 336 337 338 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 334 def act @profiler.profile do @times.times { @middleware.call_app(@new_env) } end end |
#delete_custom_params(env) ⇒ Object
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 344 def delete_custom_params(env) new_env = env.clone params = 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
340 341 342 |
# File 'lib/rack/contrib/perftools_profiler.rb', line 340 def response @middleware.profiler_data_response(@profiler.data(@data_params)) end |