Class: Exceptify::RequestContext

Inherits:
Object
  • Object
show all
Defined in:
lib/exceptify/request_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ RequestContext

Returns a new instance of RequestContext.



9
10
11
# File 'lib/exceptify/request_context.rb', line 9

def initialize(env)
  @env = env
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



7
8
9
# File 'lib/exceptify/request_context.rb', line 7

def env
  @env
end

Instance Method Details

#controllerObject



21
22
23
# File 'lib/exceptify/request_context.rb', line 21

def controller
  env["action_controller.instance"] if present?
end

#controller_and_actionObject



25
26
27
# File 'lib/exceptify/request_context.rb', line 25

def controller_and_action
  "#{controller.controller_name}##{controller.action_name}" if controller
end

#exception_dataObject



29
30
31
32
33
# File 'lib/exceptify/request_context.rb', line 29

def exception_data
  return {} unless present?

  env["exceptify.exception_data"] || {}
end

#present?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/exceptify/request_context.rb', line 13

def present?
  !env.nil?
end

#requestObject



17
18
19
# File 'lib/exceptify/request_context.rb', line 17

def request
  @request ||= ActionDispatch::Request.new(env) if present?
end