module VCR::Normalizers::Body
@private
Public Class Methods
included(klass)
click to toggle source
# File lib/vcr/structs.rb, line 10 def self.included(klass) klass.extend ClassMethods end
new(*args)
click to toggle source
Calls superclass method
# File lib/vcr/structs.rb, line 61 def initialize(*args) super if body && !body.is_a?(String) raise ArgumentError, "#{self.class} initialized with an invalid body: #{body.inspect}." end # Ensure that the body is a raw string, in case the string instance # has been subclassed or extended with additional instance variables # or attributes, so that it is serialized to YAML as a raw string. # This is needed for rest-client. See this ticket for more info: # http://github.com/myronmarston/vcr/issues/4 self.body = String.new(body.to_s) end
Private Instance Methods
base_body_hash(body)
click to toggle source
# File lib/vcr/structs.rb, line 87 def base_body_hash(body) { 'encoding' => body.encoding.name } end
serializable_body()
click to toggle source
# File lib/vcr/structs.rb, line 78 def serializable_body if VCR.configuration.preserve_exact_body_bytes_for?(self) base_body_hash(body).merge('base64_string' => Base64.encode64(body)) else base_body_hash(body).merge('string' => body) end end