Class: Imperium::TransactionResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/imperium/transaction_response.rb

Overview

A Response is a decorator around the HTTP::Message object returned when a transaction is made.

It exposes, through a convenient API, headers common to all interactions with the Consul HTTP API

Instance Method Summary collapse

Methods inherited from Response

#coerced_body, #each, #index, #initialize, #known_leader?, #last_contact, #not_found?, #translate_addresses?

Constructor Details

This class inherits a constructor from Imperium::Response

Instance Method Details

#errorsObject

Add Errors to the response coerced body

Returns:

  • the error



21
22
23
# File 'lib/imperium/transaction_response.rb', line 21

def errors
  coerced_body['Errors']
end

#resultsObject

Add Results as a KVPair to the response coerced body

Returns:

  • Imperium::KVPair



12
13
14
15
16
# File 'lib/imperium/transaction_response.rb', line 12

def results
  coerced_body['Results'].map do |result|
    KVPair.new(result['KV']) if result['KV']
  end
end