class Consul::Async::JSONResult

Result from call to a Remote JSON endpoint

Attributes

data[R]
http[R]
last_update[R]
retry_in[R]
stats[R]

Public Class Methods

new(data, modified, http, stats, retry_in, fake: false) click to toggle source
# File lib/consul/async/json_endpoint.rb, line 47
def initialize(data, modified, http, stats, retry_in, fake: false)
  @data = data
  @modified = modified
  @http = http
  @last_update = Time.now.utc
  @stats = stats
  @retry_in = retry_in
  @fake = fake
end

Public Instance Methods

fake?() click to toggle source
# File lib/consul/async/json_endpoint.rb, line 57
def fake?
  @fake
end
json() click to toggle source
# File lib/consul/async/json_endpoint.rb, line 70
def json
  @json ||= JSON.parse(data)
end
modified?() click to toggle source
# File lib/consul/async/json_endpoint.rb, line 61
def modified?
  @modified
end
mutate(new_data) click to toggle source
# File lib/consul/async/json_endpoint.rb, line 65
def mutate(new_data)
  @data = new_data.dup
  @json = nil
end
next_retry_at() click to toggle source
# File lib/consul/async/json_endpoint.rb, line 74
def next_retry_at
  next_retry + last_update
end