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
Overview
Keeps track of the cassette serializers in a hash-like object.
Defined Under Namespace
Modules: 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.
11 12 13 |
# File 'lib/vcr/cassette/serializers.rb', line 11 def initialize @serializers = {} end |
Instance Method Details
#[](name) ⇒ Object
Gets the named serializer.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vcr/cassette/serializers.rb', line 20 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 else raise ArgumentError.new("The requested VCR cassette serializer (#{name.inspect}) is not registered.") end end end |
#[]=(name, value) ⇒ Object
Registers a serializer.
37 38 39 40 41 42 43 |
# File 'lib/vcr/cassette/serializers.rb', line 37 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 |