Class: Consul::Async::ConsulTemplateNode

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

Overview

Get information about a single node

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) ⇒ ConsulTemplateNode

Returns a new instance of ConsulTemplateNode.



634
635
636
# File 'lib/consul/async/consul_template.rb', line 634

def initialize(consul_endpoint)
  super(consul_endpoint)
end

Dynamic Method Handling

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

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


638
639
640
# File 'lib/consul/async/consul_template.rb', line 638

def exists?
  !result_delegate.nil?
end

#nodeObject



653
654
655
# File 'lib/consul/async/consul_template.rb', line 653

def node
  safe_get['Node'] || {}
end

#safe_getObject



642
643
644
645
646
647
648
649
650
651
# File 'lib/consul/async/consul_template.rb', line 642

def safe_get
  if exists?
    result_delegate
  else
    {
      'Node': {},
      'Services': {}
    }
  end
end

#servicesObject



657
658
659
# File 'lib/consul/async/consul_template.rb', line 657

def services
  safe_get['Services'] || {}
end