Class: YmlErrorResponder::ErrorHandlers::BaseErrorHandler
- Inherits:
-
Object
- Object
- YmlErrorResponder::ErrorHandlers::BaseErrorHandler
- Defined in:
- lib/yml_error_responder/error_handlers/base_error_handler.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#handler_data ⇒ Object
Returns the value of attribute handler_data.
Instance Method Summary collapse
- #as_json ⇒ Object
- #http_code ⇒ Object
-
#initialize(error, handler_data) ⇒ BaseErrorHandler
constructor
A new instance of BaseErrorHandler.
- #meta ⇒ Object
Constructor Details
#initialize(error, handler_data) ⇒ BaseErrorHandler
Returns a new instance of BaseErrorHandler.
6 7 8 9 |
# File 'lib/yml_error_responder/error_handlers/base_error_handler.rb', line 6 def initialize(error, handler_data) @handler_data = handler_data @error = error end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
4 5 6 |
# File 'lib/yml_error_responder/error_handlers/base_error_handler.rb', line 4 def error @error end |
#handler_data ⇒ Object
Returns the value of attribute handler_data.
4 5 6 |
# File 'lib/yml_error_responder/error_handlers/base_error_handler.rb', line 4 def handler_data @handler_data end |
Instance Method Details
#as_json ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yml_error_responder/error_handlers/base_error_handler.rb', line 19 def as_json { data: { error: { code: @handler_data[:error_code], description: @handler_data[:description] }, meta: } } end |
#http_code ⇒ Object
11 12 13 |
# File 'lib/yml_error_responder/error_handlers/base_error_handler.rb', line 11 def http_code @handler_data[:http_code] end |
#meta ⇒ Object
15 16 17 |
# File 'lib/yml_error_responder/error_handlers/base_error_handler.rb', line 15 def @error.try(:meta) || {} end |