Class: Request::Builder::Result
- Inherits:
-
Object
- Object
- Request::Builder::Result
- Defined in:
- lib/request/builder/result.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #failure? ⇒ Boolean
- #full_errors ⇒ Object
-
#initialize(response, context) ⇒ Result
constructor
A new instance of Result.
- #schema_result ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response, context) ⇒ Result
Returns a new instance of Result.
11 12 13 14 15 16 |
# File 'lib/request/builder/result.rb', line 11 def initialize(response, context) @response = response @context = context @before_validate = config.callbacks[:before_validate] @body = @before_validate ? @before_validate.call(response.body) : response.body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/request/builder/result.rb', line 4 def body @body end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/request/builder/result.rb', line 4 def context @context end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/request/builder/result.rb', line 4 def response @response end |
Instance Method Details
#failure? ⇒ Boolean
22 23 24 |
# File 'lib/request/builder/result.rb', line 22 def failure? !success? end |
#full_errors ⇒ Object
30 31 32 |
# File 'lib/request/builder/result.rb', line 30 def full_errors errors(full: true).to_h end |
#schema_result ⇒ Object
26 27 28 |
# File 'lib/request/builder/result.rb', line 26 def schema_result @schema_result ||= schema.call(body) end |
#success? ⇒ Boolean
18 19 20 |
# File 'lib/request/builder/result.rb', line 18 def success? status == 200 && schema_result.success? end |