Module: FakeRedis

Included in:
Redis::Connection::Memory
Defined in:
lib/fakeredis/sort_method.rb,
lib/fakeredis.rb,
lib/fakeredis/zset.rb,
lib/fakeredis/geo_set.rb,
lib/fakeredis/version.rb,
lib/fakeredis/minitest.rb,
lib/fakeredis/geo_commands.rb,
lib/fakeredis/bitop_command.rb,
lib/fakeredis/expiring_hash.rb,
lib/fakeredis/command_executor.rb,
lib/fakeredis/sorted_set_store.rb,
lib/fakeredis/transaction_commands.rb,
lib/fakeredis/sorted_set_argument_handler.rb

Overview

Codes are mostly referenced from MockRedis' implementation.

Defined Under Namespace

Modules: BitopCommand, CommandExecutor, GeoCommands, Minitest, SortMethod, TransactionCommands Classes: ExpiringHash, GeoSet, SortedSetArgumentHandler, SortedSetIntersectStore, SortedSetStore, SortedSetUnionStore, ZSet

Constant Summary collapse

Redis =
::Redis
VERSION =
"0.8.0"
TRANSACTION_COMMANDS =
[:discard, :exec, :multi, :watch, :unwatch, :client]

Class Method Summary collapse

Class Method Details

.disableObject


15
16
17
# File 'lib/fakeredis.rb', line 15

def self.disable
  Redis::Connection.drivers.delete_if {|driver| Redis::Connection::Memory == driver }
end

.disablingObject


19
20
21
22
23
24
25
# File 'lib/fakeredis.rb', line 19

def self.disabling
  return yield unless enabled?

  disable
  yield
  enable
end

.enableObject


7
8
9
# File 'lib/fakeredis.rb', line 7

def self.enable
  Redis::Connection.drivers << Redis::Connection::Memory unless enabled?
end

.enabled?Boolean

Returns:

  • (Boolean)

11
12
13
# File 'lib/fakeredis.rb', line 11

def self.enabled?
  Redis::Connection.drivers.last == Redis::Connection::Memory
end

.enablingObject


27
28
29
30
31
32
33
# File 'lib/fakeredis.rb', line 27

def self.enabling
  return yield if enabled?

  enable
  yield
  disable
end