myronmarston/vcr — pull request #148 by chrisle (2012-03-18 04:17:51+00:00)
Title: refactored to use a storage backend

All I did here was just move VCR.Configuration.cassette_library_dir to VCR.Cassette.StorageBackends[:file_system]

What I'm experimenting with my fork is something like this:

```
# Remain backward compatible with older configs
# Assumes c.storage_backends = :file_system
VCR.configure do |c|
c.cassette_library_dir = 'spec/cassettes'
end

# Store to a DB
VCR.configure do |c|
c.storage_backends = :db
# ???
end

# Store to BOTH disk and DB
VCR.configure do |c|
c.storage_backends = :file_system, :db
c.cassette_library_dir = 'spec/cassettes'
end

# ... meanwhile in someone's application ...
require 'vcr'
require 'mysql2'

module MyApp
....
end

module VCR
class Cassette
class StorageBackends
module Db
extend self

def storage_location
# return a string? the database name?
end

def storage_location=(db)
# connect to your db?
end

def [](key)
@mydb.find_by_key(key)
# etc..etc.
end

def []=(key, value)
@mydb.update_attribute(key: value)
# etc...etc.
end

end
end
end
end

```