Class: Corn::Rack::RequestEnv
- Inherits:
-
Object
- Object
- Corn::Rack::RequestEnv
- Defined in:
- lib/corn/rack/request_env.rb
Instance Attribute Summary collapse
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize(env, threshold) ⇒ RequestEnv
constructor
A new instance of RequestEnv.
- #report_name ⇒ Object
- #slow_request? ⇒ Boolean
- #time ⇒ Object
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_time ⇒ Object (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_name ⇒ Object
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 |
#time ⇒ Object
12 13 14 |
# File 'lib/corn/rack/request_env.rb', line 12 def time Time.now - start_time end |