class Envoy::Client::Config::Builder

Public Class Methods

new(config) click to toggle source
# File lib/envoy/client/config/builder.rb, line 5
def initialize (config)
  @config = config
end

Public Instance Methods

export(type, *args) click to toggle source
# File lib/envoy/client/config/builder.rb, line 25
def export (type, *args)
  case type
  when :tcp
    args = args[0].split(":") if args[0] and !args[1]
    args[0] ||= "127.0.0.1"
    args[1] ||= rand(16383) + 49152
    args = [:tcp, *args]
  when :unix
    args[0] ||= ".envoy.sock"
    args = [:unix, *args]
  end
  set :export, args
end
fetch(name, &block) click to toggle source
# File lib/envoy/client/config/builder.rb, line 17
def fetch (name, &block)
  if r = @config.__send__(name)
    r
  elsif block
    set(name, block.())
  end
end
localhost() click to toggle source
# File lib/envoy/client/config/builder.rb, line 43
def localhost
  export(:tcp)[1]
end
localport() click to toggle source
# File lib/envoy/client/config/builder.rb, line 47
def localport ()
  export(:tcp)[2]
end
localsock() click to toggle source
# File lib/envoy/client/config/builder.rb, line 39
def localsock ()
  export(:unix)[1]
end
run(path) click to toggle source
# File lib/envoy/client/config/builder.rb, line 9
def run (path)
  instance_eval(File.read(path), path)
end
set(name, value) click to toggle source
# File lib/envoy/client/config/builder.rb, line 13
def set (name, value)
  @config.__send__("#{name}=", value)
end