Class: VCR::Cassette::Serializers
- Inherits:
-
Object
- Object
- VCR::Cassette::Serializers
- Defined in:
- lib/vcr/cassette/serializers.rb,
lib/vcr/cassette/serializers/json.rb,
lib/vcr/cassette/serializers/syck.rb,
lib/vcr/cassette/serializers/yaml.rb,
lib/vcr/cassette/serializers/psych.rb,
lib/vcr/cassette/serializers/compressed.rb
Overview
Keeps track of the cassette serializers in a hash-like object.
Defined Under Namespace
Modules: Compressed, JSON, Psych, Syck, YAML
Instance Method Summary collapse
-
#[](name) ⇒ Object
Gets the named serializer.
-
#[]=(name, value) ⇒ Object
Registers a serializer.
-
#initialize ⇒ Serializers
constructor
A new instance of Serializers.
Constructor Details
#initialize ⇒ Serializers
Returns a new instance of Serializers.
12 13 14 |
# File 'lib/vcr/cassette/serializers.rb', line 12 def initialize @serializers = {} end |
Instance Method Details
#[](name) ⇒ Object
Gets the named serializer.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vcr/cassette/serializers.rb', line 21 def [](name) @serializers.fetch(name) do |_| @serializers[name] = case name when :yaml then YAML when :syck then Syck when :psych then Psych when :json then JSON when :compressed then Compressed else raise ArgumentError.new("The requested VCR cassette serializer (#{name.inspect}) is not registered.") end end end |
#[]=(name, value) ⇒ Object
Registers a serializer.
39 40 41 42 43 44 45 |
# File 'lib/vcr/cassette/serializers.rb', line 39 def []=(name, value) if @serializers.has_key?(name) warn "WARNING: There is already a VCR cassette serializer registered for #{name.inspect}. Overriding it." end @serializers[name] = value end |