Sha256: abfbbd6ef396df725620ff1995eda1d303f415e4fcac90c9aab197bbbf51a955

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'psych'

module VCR
  class Cassette
    class Serializers
      # The Psych serializer. Psych is the new YAML engine in ruby 1.9.
      #
      # @see JSON
      # @see Syck
      # @see YAML
      module Psych
        extend self
        extend EncodingErrorHandling

        # @private
        ENCODING_ERRORS = [ArgumentError]

        # The file extension to use for this serializer.
        #
        # @return [String] "yml"
        def file_extension
          "yml"
        end

        # Serializes the given hash using Psych.
        #
        # @param [Hash] hash the object to serialize
        # @return [String] the YAML string
        def serialize(hash)
          handle_encoding_errors do
            ::Psych.dump(hash)
          end
        end

        # Deserializes the given string using Psych.
        #
        # @param [String] string the YAML string
        # @param [Hash] hash the deserialized object
        def deserialize(string)
          handle_encoding_errors do
            ::Psych.load(string)
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vcr-2.1.1 lib/vcr/cassette/serializers/psych.rb
vcr-2.1.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.0.1 lib/vcr/cassette/serializers/psych.rb
vcr-2.0.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.0.0.rc2 lib/vcr/cassette/serializers/psych.rb