Module: VCR::Cassette::Serializers::Psych

Extended by:
EncodingErrorHandling, Psych
Included in:
Psych
Defined in:
lib/vcr/cassette/serializers/psych.rb

Overview

The Psych serializer. Psych is the new YAML engine in ruby 1.9.

See Also:

Constant Summary collapse

ENCODING_ERRORS =
[ArgumentError]

Instance Method Summary collapse

Methods included from EncodingErrorHandling

handle_encoding_errors

Instance Method Details

#deserialize(string) ⇒ Hash

Deserializes the given string using Psych.

Parameters:

  • string (String)

    the YAML string

Returns:

  • (Hash)

    the deserialized object



39
40
41
42
43
# File 'lib/vcr/cassette/serializers/psych.rb', line 39

def deserialize(string)
  handle_encoding_errors do
    ::Psych.load(string)
  end
end

#file_extensionString

The file extension to use for this serializer.

Returns:

  • (String)

    “yml”



21
22
23
# File 'lib/vcr/cassette/serializers/psych.rb', line 21

def file_extension
  "yml"
end

#serialize(hash) ⇒ String

Serializes the given hash using Psych.

Parameters:

  • hash (Hash)

    the object to serialize

Returns:

  • (String)

    the YAML string



29
30
31
32
33
# File 'lib/vcr/cassette/serializers/psych.rb', line 29

def serialize(hash)
  handle_encoding_errors do
    ::Psych.dump(hash)
  end
end