Class: Rack::PerftoolsProfiler::StartProfiling

Inherits:
Action
  • Object
show all
Includes:
Utils
Defined in:
lib/rack/perftools_profiler/start_profiling.rb

Instance Method Summary collapse

Methods included from Utils

#let

Methods inherited from Action

for_env

Constructor Details

#initialize(*args) ⇒ StartProfiling

Returns a new instance of StartProfiling.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rack/perftools_profiler/start_profiling.rb', line 6

def initialize(*args)
  super
  request = Rack::Request.new(@env)
  @mode = let(request.GET['mode']) do |m|
    if m.nil? || m.empty?
      nil
    else
      m.to_sym
    end
  end
end

Instance Method Details

#actObject



18
19
20
# File 'lib/rack/perftools_profiler/start_profiling.rb', line 18

def act
  @profiler.start(@mode)
end

#responseObject



22
23
24
25
26
27
28
29
30
# File 'lib/rack/perftools_profiler/start_profiling.rb', line 22

def response
  [200, {'Content-Type' => 'text/plain'}, 
   [<<-EOS
Profiling is now enabled.
Visit the URLS that should be profiled.
When you are finished, visit /__stop__, then visit /__data__ to view the results.
EOS
   ]]
end