Class: Consul::Async::ConsulTemplateService

Inherits:
ConsulTemplateAbstractMap show all
Defined in:
lib/consul/async/consul_template.rb

Overview

Representation as a Map of a Service (includes Service, Node, Checks)

Instance Attribute Summary

Attributes inherited from ConsulTemplateAbstract

#endpoint, #result, #seen_at

Instance Method Summary collapse

Methods inherited from ConsulTemplateAbstract

#_seen_at, #method_missing, #ready?, #respond_to_missing?

Constructor Details

#initialize(consul_endpoint) ⇒ ConsulTemplateService

Returns a new instance of ConsulTemplateService.



560
561
562
563
564
# File 'lib/consul/async/consul_template.rb', line 560

def initialize(consul_endpoint)
  super(consul_endpoint)
  @cached_result = []
  @cached_json = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Consul::Async::ConsulTemplateAbstract

Instance Method Details

#result_delegateObject



566
567
568
569
570
571
572
573
574
575
576
# File 'lib/consul/async/consul_template.rb', line 566

def result_delegate
  return @cached_result if @cached_json == result.json

  new_res = []
  result.json.each do |v|
    new_res << ServiceInstance.new(v)
  end
  @cached_result = new_res
  @cached_json = result.json
  new_res
end