Class: Corn::Rack::RequestEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/corn/rack/request_env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, threshold) ⇒ RequestEnv



5
6
7
8
9
10
# File 'lib/corn/rack/request_env.rb', line 5

def initialize(env, threshold)
  @path_info = env['PATH_INFO']
  @http_host = env['HTTP_HOST']
  @threshold = threshold
  @start_time = Time.now
end

Instance Attribute Details

#start_timeObject (readonly)

Returns the value of attribute start_time.



4
5
6
# File 'lib/corn/rack/request_env.rb', line 4

def start_time
  @start_time
end

Instance Method Details

#report_nameObject



20
21
22
23
# File 'lib/corn/rack/request_env.rb', line 20

def report_name
  File.join(*[@http_host,
              @path_info].compact)
end

#slow_request?Boolean



16
17
18
# File 'lib/corn/rack/request_env.rb', line 16

def slow_request?
  time > @threshold
end

#timeObject



12
13
14
# File 'lib/corn/rack/request_env.rb', line 12

def time
  Time.now - start_time
end