Class: RailsErrorDashboard::ValueObjects::ErrorContext
- Inherits:
-
Object
- Object
- RailsErrorDashboard::ValueObjects::ErrorContext
- Defined in:
- lib/rails_error_dashboard/value_objects/error_context.rb
Overview
Immutable value object representing error context Extracts and normalizes context information from various sources
Instance Attribute Summary collapse
-
#action_name ⇒ Object
readonly
Returns the value of attribute action_name.
-
#controller_name ⇒ Object
readonly
Returns the value of attribute controller_name.
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#request_params ⇒ Object
readonly
Returns the value of attribute request_params.
-
#request_url ⇒ Object
readonly
Returns the value of attribute request_url.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(context, source = nil) ⇒ ErrorContext
constructor
A new instance of ErrorContext.
- #to_h ⇒ Object
Constructor Details
#initialize(context, source = nil) ⇒ ErrorContext
Returns a new instance of ErrorContext.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 11 def initialize(context, source = nil) @context = context @source = source @user_id = extract_user_id @request_url = build_request_url @request_params = extract_params @user_agent = extract_user_agent @ip_address = extract_ip_address @platform = detect_platform @controller_name = extract_controller_name @action_name = extract_action_name @request_id = extract_request_id @session_id = extract_session_id end |
Instance Attribute Details
#action_name ⇒ Object (readonly)
Returns the value of attribute action_name.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def action_name @action_name end |
#controller_name ⇒ Object (readonly)
Returns the value of attribute controller_name.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def controller_name @controller_name end |
#ip_address ⇒ Object (readonly)
Returns the value of attribute ip_address.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def ip_address @ip_address end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def platform @platform end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def request_id @request_id end |
#request_params ⇒ Object (readonly)
Returns the value of attribute request_params.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def request_params @request_params end |
#request_url ⇒ Object (readonly)
Returns the value of attribute request_url.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def request_url @request_url end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def session_id @session_id end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def user_agent @user_agent end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
8 9 10 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 8 def user_id @user_id end |
Instance Method Details
#to_h ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rails_error_dashboard/value_objects/error_context.rb', line 27 def to_h { user_id: user_id, request_url: request_url, request_params: request_params, user_agent: user_agent, ip_address: ip_address, platform: platform, controller_name: controller_name, action_name: action_name } end |