Method: Proxifier::Proxify#initialize_with_proxy

Defined in:
lib/proxifier/env.rb

#initialize_with_proxy(host, port, options_or_local_host = {}, local_port = nil, options_if_local_host = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/proxifier/env.rb', line 30

def initialize_with_proxy(host, port, options_or_local_host = {}, local_port = nil, options_if_local_host = {})
  if options_or_local_host.is_a?(Hash)
    local_host = nil
    options = options_or_local_host
  else
    local_host = options_or_local_host
    options = options_if_local_host
  end

  if options[:proxy] && (proxy = Proxifier::Proxy(options.delete(:proxy), options)) && proxy.proxify?(host)
    initialize_without_proxy(proxy.host, proxy.port, local_host, local_port)
    begin
      proxy.proxify(self, host, port)
    rescue
      close
      raise
    end
  else
    initialize_without_proxy(host, port, local_host, local_port)
  end
end