Class: Imperium::KVPUTResponse
- Defined in:
- lib/imperium/kv_put_response.rb
Overview
Note:
This class doesn’t really make sense to be instantiated outside of Imperium::KV#put
KVPUTResponse is a wrapper for the raw HTTP::Message response from the API
Instance Attribute Summary collapse
-
#options ⇒ Hash<Symbol, Object>
coerced from an array to hash.
-
#prefix ⇒ String
returned values from the API into their various shapes.
Instance Method Summary collapse
-
#initialize(message, options: {}) ⇒ KVPUTResponse
constructor
A new instance of KVPUTResponse.
- #success? ⇒ Boolean
Methods inherited from Response
#known_leader?, #last_contact, #not_found?, #translate_addresses?
Constructor Details
#initialize(message, options: {}) ⇒ KVPUTResponse
Returns a new instance of KVPUTResponse.
18 19 20 21 |
# File 'lib/imperium/kv_put_response.rb', line 18 def initialize(, options: {}) super @options = end |
Instance Attribute Details
#options ⇒ Hash<Symbol, Object>
coerced from an array to hash.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/imperium/kv_put_response.rb', line 15 class KVPUTResponse < Response attr_accessor :options def initialize(, options: {}) super @options = end if RUBY_VERSION < "2.4" def success? return @success if defined? @success @success = (body.chomp == "true") end else def success? return @success if defined? @success @success = JSON.parse(body) rescue JSON::ParserError body.empty? ? @success = false : raise end end end |
#prefix ⇒ String
returned values from the API into their various shapes.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/imperium/kv_put_response.rb', line 15 class KVPUTResponse < Response attr_accessor :options def initialize(, options: {}) super @options = end if RUBY_VERSION < "2.4" def success? return @success if defined? @success @success = (body.chomp == "true") end else def success? return @success if defined? @success @success = JSON.parse(body) rescue JSON::ParserError body.empty? ? @success = false : raise end end end |
Instance Method Details
#success? ⇒ Boolean
24 25 26 27 |
# File 'lib/imperium/kv_put_response.rb', line 24 def success? return @success if defined? @success @success = (body.chomp == "true") end |