Class: MemoryTracker::Env
- Inherits:
-
Object
- Object
- MemoryTracker::Env
- Defined in:
- lib/memory_tracker/env.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(env) ⇒ Env
constructor
A new instance of Env.
Constructor Details
#initialize(env) ⇒ Env
Returns a new instance of Env.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/memory_tracker/env.rb', line 5 def initialize(env) @path = env['PATH_INFO'] begin routes_env = { :method => env['REQUEST_METHOD'] } request = Rails.application.routes.recognize_path(env['REQUEST_PATH'], routes_env) @controller = request[:controller] @action = request[:action] rescue ActionController::RoutingError @controller = 'unknown' @action = 'unknown' end end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/memory_tracker/env.rb', line 3 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
3 4 5 |
# File 'lib/memory_tracker/env.rb', line 3 def controller @controller end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/memory_tracker/env.rb', line 3 def path @path end |