Module: VCR::Cassette::Serializers::Psych
Overview
The Psych serializer. Psych is the new YAML engine in ruby 1.9.
Instance Method Summary collapse
-
#deserialize(string) ⇒ Hash
Deserializes the given string using Psych.
-
#file_extension ⇒ String
The file extension to use for this serializer.
-
#serialize(hash) ⇒ String
Serializes the given hash using Psych.
Instance Method Details
#deserialize(string) ⇒ Hash
Deserializes the given string using Psych.
45 46 47 48 49 50 51 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 45 def deserialize(string) handle_encoding_errors do handle_syntax_errors do ::Psych.load(string) end end end |
#file_extension ⇒ String
The file extension to use for this serializer.
25 26 27 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 25 def file_extension "yml" end |
#serialize(hash) ⇒ String
Serializes the given hash using Psych.
33 34 35 36 37 38 39 |
# File 'lib/vcr/cassette/serializers/psych.rb', line 33 def serialize(hash) handle_encoding_errors do result = ::Psych.dump(hash) result.gsub!(": \n", ": null\n") # set canonical null value in order to avoid trailing whitespaces result end end |