Class: SimplificatorInfrastructure::ErrorSummary

Inherits:
Object
  • Object
show all
Includes:
LocaleDetection
Defined in:
lib/simplificator_infrastructure/error_summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LocaleDetection

included

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

#envObject (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

#exceptionObject

extracts the exception from env



16
17
18
# File 'lib/simplificator_infrastructure/error_summary.rb', line 16

def exception
  env['action_dispatch.exception']
end

#localeObject

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

#paramsObject



20
21
22
# File 'lib/simplificator_infrastructure/error_summary.rb', line 20

def params
  env['action_dispatch.request.parameters']
end

#status_codeObject

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