Class: ConsulLoader::ResponseDecoder

Inherits:
Object
  • Object
show all
Defined in:
lib/consul_loader/response_decoder.rb

Instance Method Summary collapse

Instance Method Details

#base64_decode(value) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/consul_loader/response_decoder.rb', line 16

def base64_decode value
  begin
    return Base64.strict_decode64(value)
  rescue
    return nil
  end
end

#decode_value(response) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/consul_loader/response_decoder.rb', line 5

def decode_value response
  return nil if response == nil

  json = JSON.parse response

  return nil if json == nil
  return nil if json[0]["Value"] == nil

  base64_decode json[0]["Value"]
end