Class: Rack::PerftoolsProfiler::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/perftools_profiler/action.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, profiler, middleware) ⇒ Action

Returns a new instance of Action.



5
6
7
8
9
10
11
# File 'lib/rack/perftools_profiler/action.rb', line 5

def initialize(env, profiler, middleware)
  @env = env
  @request = Rack::Request.new(env)
  @get_params = @request.GET.clone
  @profiler = profiler
  @middleware = middleware
end

Class Method Details

.for_env(env, profiler, middleware) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rack/perftools_profiler/action.rb', line 17

def self.for_env(env, profiler, middleware)
  request = Rack::Request.new(env)
  password = request.GET['profile']
  accepted = profiler.accepts?(password)
  klass =
    case request.path_info
    when %r{/__start__$}
      password_protect(StartProfiling, accepted)
    when %r{/__stop__$}
      password_protect(StopProfiling, accepted)
    when %r{/__data__$}
      password_protect(ReturnData, accepted)
    else
      if ProfileOnce.has_special_param?(request)
        password_protect(ProfileOnce, accepted)
      else
        CallAppDirectly
      end
    end
  klass.new(env, profiler, middleware)
end

Instance Method Details

#actObject



13
14
15
# File 'lib/rack/perftools_profiler/action.rb', line 13

def act
  # do nothing
end