Class: Etcd::Response
- Inherits:
-
Object
- Object
- Etcd::Response
- Extended by:
- Forwardable
- Defined in:
- lib/etcd/response.rb
Overview
manage http responses
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#etcd_index ⇒ Object
readonly
Returns the value of attribute etcd_index.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#raft_index ⇒ Object
readonly
Returns the value of attribute raft_index.
-
#raft_term ⇒ Object
readonly
Returns the value of attribute raft_term.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts, headers = {}) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(opts, headers = {}) ⇒ Response
Returns a new instance of Response.
16 17 18 19 20 21 22 |
# File 'lib/etcd/response.rb', line 16 def initialize(opts, headers = {}) @action = opts['action'] @node = Node.new(opts['node']) @etcd_index = headers[:etcd_index] @raft_index = headers[:raft_index] @raft_term = headers[:raft_term] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
12 13 14 |
# File 'lib/etcd/response.rb', line 12 def action @action end |
#etcd_index ⇒ Object (readonly)
Returns the value of attribute etcd_index.
12 13 14 |
# File 'lib/etcd/response.rb', line 12 def etcd_index @etcd_index end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
12 13 14 |
# File 'lib/etcd/response.rb', line 12 def node @node end |
#raft_index ⇒ Object (readonly)
Returns the value of attribute raft_index.
12 13 14 |
# File 'lib/etcd/response.rb', line 12 def raft_index @raft_index end |
#raft_term ⇒ Object (readonly)
Returns the value of attribute raft_term.
12 13 14 |
# File 'lib/etcd/response.rb', line 12 def raft_term @raft_term end |
Class Method Details
.from_http_response(response) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/etcd/response.rb', line 24 def self.from_http_response(response) data = JSON.parse(response.body) headers = {} headers[:etcd_index] = response['X-Etcd-Index'].to_i headers[:raft_index] = response['X-Raft-Index'].to_i headers[:raft_term] = response['X-Raft-Term'].to_i Response.new(data, headers) end |