Class: Imperium::KVDELETEResponse

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

Overview

Note:

This class doesn’t really make sense to be instantiated outside of Imperium::KV#delete

KVDELETEResponse is a wrapper for the raw HTTP::Message response from the API

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Response

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

Constructor Details

#initialize(message, options: {}) ⇒ KVDELETEResponse

Returns a new instance of KVDELETEResponse.



15
16
17
18
# File 'lib/imperium/kv_delete_response.rb', line 15

def initialize(message, options: {})
  super message
  @options = options
end

Instance Attribute Details

#optionsHash<Symbol, Object>

coerced from an array to hash.

Returns:

  • (Hash<Symbol, Object>)

    The options for the get request after being



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/imperium/kv_delete_response.rb', line 12

class KVDELETEResponse < Response
  attr_accessor :options

  def initialize(message, options: {})
    super message
    @options = 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

Returns:

  • (Boolean)


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

def success?
  return @success if defined? @success
  @success = (body.chomp == "true")
end