Module: Typhoeus::Hydra::ConnectOptions::ClassMethods

Defined in:
lib/typhoeus/hydra/connect_options.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/typhoeus/hydra/connect_options.rb', line 23

def self.extended(base)
  class << base
    attr_accessor :allow_net_connect
    attr_accessor :ignore_localhost
  end
  base.allow_net_connect = true
  base.ignore_localhost = false
end

Instance Method Details

#allow_net_connect?boolean

Returns whether we allow external HTTP connections. Useful for mocking/tests.

Returns:

  • (boolean)

    true/false



36
37
38
# File 'lib/typhoeus/hydra/connect_options.rb', line 36

def allow_net_connect?
  allow_net_connect
end

#ignore_hostsObject



44
45
46
47
48
49
50
51
52
# File 'lib/typhoeus/hydra/connect_options.rb', line 44

def ignore_hosts
  @ignore_hosts ||= []

  if ignore_localhost?
    @ignore_hosts + Typhoeus::Request::LOCALHOST_ALIASES
  else
    @ignore_hosts
  end
end

#ignore_hosts=(hosts) ⇒ Object



54
55
56
# File 'lib/typhoeus/hydra/connect_options.rb', line 54

def ignore_hosts=(hosts)
  @ignore_hosts = hosts
end

#ignore_localhost?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/typhoeus/hydra/connect_options.rb', line 40

def ignore_localhost?
  ignore_localhost
end