Class: Consul::Async::JSONResult

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

Overview

Result from call to a Remote JSON endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, modified, http, stats, retry_in, fake: false) ⇒ JSONResult

Returns a new instance of JSONResult.



50
51
52
53
54
55
56
57
58
# File 'lib/consul/async/json_endpoint.rb', line 50

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



48
49
50
# File 'lib/consul/async/json_endpoint.rb', line 48

def data
  @data
end

#httpObject (readonly)

Returns the value of attribute http.



48
49
50
# File 'lib/consul/async/json_endpoint.rb', line 48

def http
  @http
end

#last_updateObject (readonly)

Returns the value of attribute last_update.



48
49
50
# File 'lib/consul/async/json_endpoint.rb', line 48

def last_update
  @last_update
end

#retry_inObject (readonly)

Returns the value of attribute retry_in.



48
49
50
# File 'lib/consul/async/json_endpoint.rb', line 48

def retry_in
  @retry_in
end

#statsObject (readonly)

Returns the value of attribute stats.



48
49
50
# File 'lib/consul/async/json_endpoint.rb', line 48

def stats
  @stats
end

Instance Method Details

#fake?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/consul/async/json_endpoint.rb', line 60

def fake?
  @fake
end

#jsonObject



73
74
75
# File 'lib/consul/async/json_endpoint.rb', line 73

def json
  @json ||= JSON.parse(data)
end

#modified?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/consul/async/json_endpoint.rb', line 64

def modified?
  @modified
end

#mutate(new_data) ⇒ Object



68
69
70
71
# File 'lib/consul/async/json_endpoint.rb', line 68

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

#next_retry_atObject



77
78
79
# File 'lib/consul/async/json_endpoint.rb', line 77

def next_retry_at
  next_retry + last_update
end