Sha256: c8ef58ce15e663a7995db325dc46463eda3dbcd9284de3ce048f76813dcbd457

Contents?: true

Size: 1.06 KB

Versions: 78

Compression:

Stored size: 1.06 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
        # @return [Hash] the deserialized object
        def deserialize(string)
          handle_encoding_errors do
            ::Psych.load(string)
          end
        end
      end
    end
  end
end

Version data entries

78 entries across 78 versions & 9 rubygems

Version Path
mustwin-vcr-2.9.3 lib/vcr/cassette/serializers/psych.rb
vcr-2.9.3 lib/vcr/cassette/serializers/psych.rb
vcr-2.9.2 lib/vcr/cassette/serializers/psych.rb
vcr-2.9.1 lib/vcr/cassette/serializers/psych.rb
vcr-2.9.0 lib/vcr/cassette/serializers/psych.rb
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/vcr-2.8.0/lib/vcr/cassette/serializers/psych.rb
vcr-2.8.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.7.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.6.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.5.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.4.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.3.0 lib/vcr/cassette/serializers/psych.rb
vcr-2.2.5 lib/vcr/cassette/serializers/psych.rb
vcr-2.2.4 lib/vcr/cassette/serializers/psych.rb
vcr-2.2.3 lib/vcr/cassette/serializers/psych.rb
vcr-2.2.2 lib/vcr/cassette/serializers/psych.rb
vcr-2.2.1 lib/vcr/cassette/serializers/psych.rb
vcr-2.2.0 lib/vcr/cassette/serializers/psych.rb