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
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/vcr-3.0.3/lib/vcr/cassette/persisters.rb
vcr-3.0.3 lib/vcr/cassette/persisters.rb
vcr-3.0.2 lib/vcr/cassette/persisters.rb
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/vcr-2.9.3/lib/vcr/cassette/persisters.rb
vcr-3.0.1 lib/vcr/cassette/persisters.rb
vcr-3.0.0 lib/vcr/cassette/persisters.rb
mustwin-vcr-2.9.3 lib/vcr/cassette/persisters.rb
vcr-2.9.3 lib/vcr/cassette/persisters.rb
vcr-2.9.2 lib/vcr/cassette/persisters.rb
vcr-2.9.1 lib/vcr/cassette/persisters.rb
vcr-2.9.0 lib/vcr/cassette/persisters.rb
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/vcr-2.8.0/lib/vcr/cassette/persisters.rb
vcr-2.8.0 lib/vcr/cassette/persisters.rb
vcr-2.7.0 lib/vcr/cassette/persisters.rb
vcr-2.6.0 lib/vcr/cassette/persisters.rb
vcr-2.5.0 lib/vcr/cassette/persisters.rb
vcr-2.4.0 lib/vcr/cassette/persisters.rb
vcr-2.3.0 lib/vcr/cassette/persisters.rb
vcr-2.2.5 lib/vcr/cassette/persisters.rb