Class: VCR::HTTPInteraction::HookAware

Inherits:
VCR::HTTPInteraction show all
Defined in:
lib/vcr/structs.rb

Overview

Decorates an VCR::HTTPInteraction with additional methods useful for a before_record or before_playback hook.

Instance Attribute Summary

Attributes inherited from VCR::HTTPInteraction

#recorded_at, #request, #response

Instance Method Summary collapse

Methods inherited from VCR::HTTPInteraction

from_hash, #hook_aware, #to_hash

Constructor Details

#initialize(http_interaction) ⇒ HookAware

Returns a new instance of HookAware.



539
540
541
542
# File 'lib/vcr/structs.rb', line 539

def initialize(http_interaction)
  @ignored = false
  super
end

Instance Method Details

#filter!(text, replacement_text) ⇒ Object

Replaces a string in any part of the HTTP interaction (headers, request body, response body, etc) with the given replacement text.

Parameters:

  • text (#to_s)

    the text to replace

  • replacement_text (#to_s)

    the text to put in its place



563
564
565
566
567
# File 'lib/vcr/structs.rb', line 563

def filter!(text, replacement_text)
  text, replacement_text = text.to_s, replacement_text.to_s
  return self if [text, replacement_text].any? { |t| t.empty? }
  filter_object!(self, text, replacement_text)
end

#ignore!Object

Flags the HTTP interaction so that VCR ignores it. This is useful in a Configuration#before_record or Configuration#before_playback hook so that VCR does not record or play it back.

See Also:



548
549
550
# File 'lib/vcr/structs.rb', line 548

def ignore!
  @ignored = true
end

#ignored?Boolean

Returns whether or not this HTTP interaction should be ignored.

Returns:

  • (Boolean)

    whether or not this HTTP interaction should be ignored.

See Also:



554
555
556
# File 'lib/vcr/structs.rb', line 554

def ignored?
  !!@ignored
end