Class: Consul::Async::JSONResult
- Inherits:
-
Object
- Object
- Consul::Async::JSONResult
- Defined in:
- lib/consul/async/json_endpoint.rb
Overview
Result from call to a Remote JSON endpoint
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#last_update ⇒ Object
readonly
Returns the value of attribute last_update.
-
#retry_in ⇒ Object
readonly
Returns the value of attribute retry_in.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
Instance Method Summary collapse
- #fake? ⇒ Boolean
-
#initialize(data, modified, http, stats, retry_in, fake: false) ⇒ JSONResult
constructor
A new instance of JSONResult.
- #json ⇒ Object
- #modified? ⇒ Boolean
- #mutate(new_data) ⇒ Object
- #next_retry_at ⇒ Object
Constructor Details
#initialize(data, modified, http, stats, retry_in, fake: false) ⇒ JSONResult
Returns a new instance of JSONResult.
47 48 49 50 51 52 53 54 55 |
# 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 |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
46 47 48 |
# File 'lib/consul/async/json_endpoint.rb', line 46 def data @data end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
46 47 48 |
# File 'lib/consul/async/json_endpoint.rb', line 46 def http @http end |
#last_update ⇒ Object (readonly)
Returns the value of attribute last_update.
46 47 48 |
# File 'lib/consul/async/json_endpoint.rb', line 46 def last_update @last_update end |
#retry_in ⇒ Object (readonly)
Returns the value of attribute retry_in.
46 47 48 |
# File 'lib/consul/async/json_endpoint.rb', line 46 def retry_in @retry_in end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
46 47 48 |
# File 'lib/consul/async/json_endpoint.rb', line 46 def stats @stats end |
Instance Method Details
#fake? ⇒ Boolean
57 58 59 |
# File 'lib/consul/async/json_endpoint.rb', line 57 def fake? @fake end |
#json ⇒ Object
70 71 72 |
# File 'lib/consul/async/json_endpoint.rb', line 70 def json @json ||= JSON.parse(data) end |
#modified? ⇒ Boolean
61 62 63 |
# File 'lib/consul/async/json_endpoint.rb', line 61 def modified? @modified end |
#mutate(new_data) ⇒ Object
65 66 67 68 |
# File 'lib/consul/async/json_endpoint.rb', line 65 def mutate(new_data) @data = new_data.dup @json = nil end |
#next_retry_at ⇒ Object
74 75 76 |
# File 'lib/consul/async/json_endpoint.rb', line 74 def next_retry_at next_retry + last_update end |