class Consul::Data

Public Class Methods

new(response_hash) click to toggle source
# File lib/consul/data.rb, line 10
def initialize(response_hash)
  @response = response_hash
end

Public Instance Methods

a()
Alias for: flags
flags() click to toggle source
# File lib/consul/data.rb, line 19
def flags
  hash_map(__callee__)
end
Also aliased as: a
value() click to toggle source
# File lib/consul/data.rb, line 14
def value
  text = Base64.decode64(hash_map('Value'))
  try_decode(text)
end

Private Instance Methods

hash_map(key) click to toggle source
# File lib/consul/data.rb, line 25
def hash_map(key)
  @response[key.to_s.split('_').map{ |w| w.capitalize }.join]
end
try_decode(text) click to toggle source
# File lib/consul/data.rb, line 29
def try_decode(text)
  begin
    decoded = Consul::Client.decode(text)
  rescue Psych::DisallowedClass, Psych::SyntaxError
  end
  decoded || text
end