Module: OpenapiFirst::ErrorResponse
- Defined in:
- lib/openapi_first/error_response.rb
Overview
This is the base module for error responses
Instance Attribute Summary collapse
-
#failure ⇒ Object
readonly
Returns the value of attribute failure.
Instance Method Summary collapse
-
#body ⇒ Object
The response body.
-
#content_type ⇒ Object
The response content-type.
- #initialize(failure: nil) ⇒ Object
-
#render ⇒ Object
Render this error response.
-
#status ⇒ Object
The response status.
Instance Attribute Details
#failure ⇒ Object (readonly)
Returns the value of attribute failure.
11 12 13 |
# File 'lib/openapi_first/error_response.rb', line 11 def failure @failure end |
Instance Method Details
#body ⇒ Object
The response body
14 15 16 |
# File 'lib/openapi_first/error_response.rb', line 14 def body raise "#{self.class} must implement the method #{__method__}" end |
#content_type ⇒ Object
The response content-type
19 20 21 |
# File 'lib/openapi_first/error_response.rb', line 19 def content_type raise "#{self.class} must implement the method #{__method__}" end |
#initialize(failure: nil) ⇒ Object
7 8 9 |
# File 'lib/openapi_first/error_response.rb', line 7 def initialize(failure: nil) @failure = failure end |
#render ⇒ Object
Render this error response
36 37 38 |
# File 'lib/openapi_first/error_response.rb', line 36 def render Rack::Response.new(body, status, Rack::CONTENT_TYPE => content_type).finish end |
#status ⇒ Object
The response status
31 32 33 |
# File 'lib/openapi_first/error_response.rb', line 31 def status STATUS[failure.type] || 400 end |