Class: Consul::Async::VaultResult

Inherits:
Object
  • Object
show all
Defined in:
lib/consul/async/vault_endpoint.rb

Overview

Keep information about Vault result of a query

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result, modified, stats, retry_in) ⇒ VaultResult

Returns a new instance of VaultResult.



81
82
83
84
85
86
87
88
89
90
# File 'lib/consul/async/vault_endpoint.rb', line 81

def initialize(result, modified, stats, retry_in)
  @data = result.response
  @modified = modified
  @http = result
  @data_json = result.json
  @last_update = Time.now.utc
  @next_update = Time.now.utc + retry_in
  @stats = stats
  @retry_in = retry_in
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



79
80
81
# File 'lib/consul/async/vault_endpoint.rb', line 79

def data
  @data
end

#httpObject (readonly)

Returns the value of attribute http.



79
80
81
# File 'lib/consul/async/vault_endpoint.rb', line 79

def http
  @http
end

#retry_inObject (readonly)

Returns the value of attribute retry_in.



79
80
81
# File 'lib/consul/async/vault_endpoint.rb', line 79

def retry_in
  @retry_in
end

#statsObject (readonly)

Returns the value of attribute stats.



79
80
81
# File 'lib/consul/async/vault_endpoint.rb', line 79

def stats
  @stats
end

Instance Method Details

#[](path) ⇒ Object



101
102
103
# File 'lib/consul/async/vault_endpoint.rb', line 101

def [](path)
  json[path]
end

#jsonObject



105
106
107
108
# File 'lib/consul/async/vault_endpoint.rb', line 105

def json
  @data_json = JSON.parse(data) if @data_json.nil?
  @data_json
end

#modified?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/consul/async/vault_endpoint.rb', line 92

def modified?
  @modified
end

#mutate(new_data) ⇒ Object



96
97
98
99
# File 'lib/consul/async/vault_endpoint.rb', line 96

def mutate(new_data)
  @data = new_data.dup
  @data_json = nil
end