Class: Consul::Async::ConsulTemplateServices

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

Overview

Object returned by services() an abstract map of service_name, tags

Instance Attribute Summary

Attributes inherited from ConsulTemplateAbstract

#endpoint, #result, #seen_at

Instance Method Summary collapse

Methods inherited from ConsulTemplateAbstract

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

Constructor Details

This class inherits a constructor from Consul::Async::ConsulTemplateAbstract

Dynamic Method Handling

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

Instance Method Details

#parse_result(res) ⇒ Object



586
587
588
589
590
591
592
593
594
595
596
# File 'lib/consul/async/consul_template.rb', line 586

def parse_result(res)
  return res unless res.data == '{}' || endpoint.query_params[:tag]

  res_json = JSON.parse(res.data)
  result = {}
  res_json.each do |name, tags|
    result[name] = tags if tags.include? endpoint.query_params[:tag]
  end
  res.mutate(JSON.generate(result))
  res
end