Class: MemoryTracker::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/memory_tracker/env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/memory_tracker/env.rb', line 3

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller.



3
4
5
# File 'lib/memory_tracker/env.rb', line 3

def controller
  @controller
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/memory_tracker/env.rb', line 3

def path
  @path
end