Class: FHTTPClient::Processor::Response
- Extended by:
- Forwardable
- Defined in:
- lib/f_http_client/processor/response.rb
Overview
This Service proccess a HTTP response, generating a success or failure result.
Example:
def process
response = OpenStruct.new(success?: false, parsed_response: {}, headers: {}, message: 'Conflict')
processor = FHTTPClient::Processor::Response.new(response: response)
processor.()
.on_success { |value| "Success! #{value.inspect}"}
.on_failure(:conflict) { |value| return "A conflict happened! #{value.inspect}"}
.on_failure(:client_error) { |value| return "An unexpected client error happened #{value.inspect}"}
.on_failure { |value| return "Generic #{value}" }
end
proccess # => “A conflict happened! {}”
Instance Method Summary collapse
Instance Method Details
#run ⇒ Object
37 38 39 |
# File 'lib/f_http_client/processor/response.rb', line 37 def run log_data.and_then { success? ? success_response : failure_response } end |