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.



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

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.



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

def data
  @data
end

#httpObject (readonly)

Returns the value of attribute http.



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

def http
  @http
end

#retry_inObject (readonly)

Returns the value of attribute retry_in.



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

def retry_in
  @retry_in
end

#statsObject (readonly)

Returns the value of attribute stats.



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

def stats
  @stats
end

Instance Method Details

#[](path) ⇒ Object



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

def [](path)
  json[path]
end

#jsonObject



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

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

#modified?Boolean

Returns:

  • (Boolean)


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

def modified?
  @modified
end

#mutate(new_data) ⇒ Object



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

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