Class: VCR::RequestIgnorer

Inherits:
Object
  • Object
show all
Includes:
Hooks
Defined in:
lib/vcr/request_ignorer.rb

Constant Summary collapse

LOCALHOST_ALIASES =
%w( localhost 127.0.0.1 0.0.0.0 )

Instance Method Summary collapse

Methods included from Hooks

#clear_hooks, #has_hooks_for?, #hooks, included, #invoke_hook

Methods included from VariableArgsBlockCaller

#call_block

Constructor Details

#initializeRequestIgnorer

Returns a new instance of RequestIgnorer.



13
14
15
16
17
18
# File 'lib/vcr/request_ignorer.rb', line 13

def initialize
  ignore_request do |request|
    host = request.parsed_uri.host
    ignored_hosts.include?(host)
  end
end

Instance Method Details

#ignore?(request) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/vcr/request_ignorer.rb', line 32

def ignore?(request)
  invoke_hook(:ignore_request, request).any?
end

#ignore_hosts(*hosts) ⇒ Object



28
29
30
# File 'lib/vcr/request_ignorer.rb', line 28

def ignore_hosts(*hosts)
  ignored_hosts.merge(hosts)
end

#ignore_localhost=(value) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/vcr/request_ignorer.rb', line 20

def ignore_localhost=(value)
  if value
    ignore_hosts(*LOCALHOST_ALIASES)
  else
    ignored_hosts.reject! { |h| LOCALHOST_ALIASES.include?(h) }
  end
end