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.



523
524
525
526
# File 'lib/vcr/structs.rb', line 523

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



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

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:



532
533
534
# File 'lib/vcr/structs.rb', line 532

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:



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

def ignored?
  !!@ignored
end