module VCR::Cassette::Serializers::Syck

The Syck serializer. Syck is the legacy YAML engine in ruby 1.8 and 1.9.

@see JSON @see Psych @see YAML

Constants

ENCODING_ERRORS

@private

Public Instance Methods

deserialize(string) click to toggle source

Deserializes the given string using Syck.

@param [String] string the YAML string @return [Hash] the deserialized object

# File lib/vcr/cassette/serializers/syck.rb, line 39
def deserialize(string)
  handle_encoding_errors do
    using_syck { ::YAML.load(string) }
  end
end
file_extension() click to toggle source

The file extension to use for this serializer.

@return [String] “yml”

# File lib/vcr/cassette/serializers/syck.rb, line 21
def file_extension
  "yml"
end
serialize(hash) click to toggle source

Serializes the given hash using Syck.

@param [Hash] hash the object to serialize @return [String] the YAML string

# File lib/vcr/cassette/serializers/syck.rb, line 29
def serialize(hash)
  handle_encoding_errors do
    using_syck { ::YAML.dump(hash) }
  end
end

Private Instance Methods

using_syck() { || ... } click to toggle source
# File lib/vcr/cassette/serializers/syck.rb, line 47
def using_syck
  return yield unless defined?(::YAML::ENGINE)
  original_engine = ::YAML::ENGINE.yamler
  ::YAML::ENGINE.yamler = 'syck'

  begin
    yield
  ensure
    ::YAML::ENGINE.yamler = original_engine
  end
end