Sha256: 841bf3e593b970ae70a7803125d2ed4036f40d8c0896b5b89d4a1b4e0071736a

Contents?: true

Size: 643 Bytes

Versions: 4

Compression:

Stored size: 643 Bytes

Contents

require 'database_cleaner/generic/base'

module DatabaseCleaner
  module Redis
    def self.available_strategies
      %w{truncation}
    end

    module Base
      include ::DatabaseCleaner::Generic::Base

      def db=(desired_db)
        @db = desired_db
      end

      def db
        @db ||= :default
      end

      alias url db

      private

      def connection
        @connection ||= begin
          if url == :default
            ::Redis.new
          elsif db.is_a?(::Redis) # pass directly the connection
            db
          else
            ::Redis.new(:url => url)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
database_cleaner-1.7.0 lib/database_cleaner/redis/base.rb
database_cleaner-1.6.2 lib/database_cleaner/redis/base.rb
database_cleaner-1.6.1 lib/database_cleaner/redis/base.rb
database_cleaner-1.6.0 lib/database_cleaner/redis/base.rb