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)
  @data_params = @request.params.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
# File 'lib/rack/perftools_profiler/action.rb', line 17

def self.for_env(env, profiler, middleware)
  request = Rack::Request.new(env)
  klass = 
    case request.path
    when '/__start__'
      StartProfiling
    when '/__stop__'
      StopProfiling
    when '/__data__'
      ReturnData
    else
      if ProfileOnce.has_special_param?(request)
        ProfileOnce
      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