Sha256: e1bae91a7244b6ca15fd44977c29a1bad73f721f2fb46bc2b3e48f17d44e866a

Contents?: true

Size: 1.24 KB

Versions: 85

Compression:

Stored size: 1.24 KB

Contents

module VCR
  class Cassette
    # Keeps track of the cassette persisters in a hash-like object.
    class Persisters
      autoload :FileSystem, 'vcr/cassette/persisters/file_system'

      # @private
      def initialize
        @persisters = {}
      end

      # Gets the named persister.
      #
      # @param name [Symbol] the name of the persister
      # @return the named persister
      # @raise [ArgumentError] if there is not a persister for the given name
      def [](name)
        @persisters.fetch(name) do |_|
          @persisters[name] = case name
            when :file_system then FileSystem
            else raise ArgumentError, "The requested VCR cassette persister " +
                                      "(#{name.inspect}) is not registered."
          end
        end
      end

      # Registers a persister.
      #
      # @param name [Symbol] the name of the persister
      # @param value [#[], #[]=] the persister object. It must implement `[]` and `[]=`.
      def []=(name, value)
        if @persisters.has_key?(name)
          warn "WARNING: There is already a VCR cassette persister " +
               "registered for #{name.inspect}. Overriding it."
        end

        @persisters[name] = value
      end

    end
  end
end

Version data entries

85 entries across 85 versions & 10 rubygems

Version Path
cloudsmith-api-2.0.16 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.15 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.14 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
vcr-6.3.1 lib/vcr/cassette/persisters.rb
vcr-6.3.0 lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.13 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.12 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.11 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.10 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.9 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.8 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.7 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
vcr-6.2.0 lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.6 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.5 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.4 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.3 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.2 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/vcr-6.1.0/lib/vcr/cassette/persisters.rb
cloudsmith-api-2.0.1 vendor/bundle/ruby/2.6.0/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb