Class: SimplificatorInfrastructure::ErrorSummary
- Inherits:
-
Object
- Object
- SimplificatorInfrastructure::ErrorSummary
- Includes:
- LocaleDetection
- Defined in:
- lib/simplificator_infrastructure/error_summary.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
-
#exception ⇒ Object
extracts the exception from env.
-
#initialize(env) ⇒ ErrorSummary
constructor
A new instance of ErrorSummary.
-
#locale ⇒ Object
tries to detect locale based on #available_locales and a locale which is in the path, in params (:locale), in the accept header or default.
- #params ⇒ Object
-
#status_code ⇒ Object
detects the status code based on the exception that was thrown.
Methods included from LocaleDetection
Constructor Details
#initialize(env) ⇒ ErrorSummary
Returns a new instance of ErrorSummary.
6 7 8 |
# File 'lib/simplificator_infrastructure/error_summary.rb', line 6 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
4 5 6 |
# File 'lib/simplificator_infrastructure/error_summary.rb', line 4 def env @env end |
Instance Method Details
#exception ⇒ Object
extracts the exception from env
16 17 18 |
# File 'lib/simplificator_infrastructure/error_summary.rb', line 16 def exception env['action_dispatch.exception'] end |
#locale ⇒ Object
tries to detect locale based on #available_locales and a locale which is in the path, in params (:locale), in the accept header or default
26 27 28 |
# File 'lib/simplificator_infrastructure/error_summary.rb', line 26 def locale locale_from_path || locale_from_params || locale_from_header || locale_default end |
#params ⇒ Object
20 21 22 |
# File 'lib/simplificator_infrastructure/error_summary.rb', line 20 def params env['action_dispatch.request.parameters'] end |
#status_code ⇒ Object
detects the status code based on the exception that was thrown
11 12 13 |
# File 'lib/simplificator_infrastructure/error_summary.rb', line 11 def status_code @status_code ||= ActionDispatch::ExceptionWrapper.new(env, exception).status_code end |