class DiscoveryEtcdIoClient

Constants

VERSION

Attributes

token[R]

Public Class Methods

new(opts = {}) click to toggle source
Calls superclass method
# File lib/discovery_etcd_io_client.rb, line 7
def initialize(opts = {})
  super
  @host = 'discovery.etcd.io'
  @port = 80
  @token = opts[:token] || raise
end

Public Instance Methods

[](key) click to toggle source
# File lib/discovery_etcd_io_client.rb, line 18
def [](key)
  get('/' + key).value
rescue Etcd::KeyNotFound
end
[]=(key, value) click to toggle source
# File lib/discovery_etcd_io_client.rb, line 23
def []=(key, value)
  set('/' + key, value: value)
end
key_endpoint() click to toggle source
# File lib/discovery_etcd_io_client.rb, line 14
def key_endpoint
  '/' + @token
end
to_h() click to toggle source
# File lib/discovery_etcd_io_client.rb, line 27
def to_h
  hash = get('').children.each_with_object({}) do |node, new_hash|
    key   = node.key.split('/').last
    value = node.value
    new_hash[key] = value
  end
  Hash[*hash.sort.flatten]
end
to_s() click to toggle source
# File lib/discovery_etcd_io_client.rb, line 36
def to_s
  to_h.to_s
end