Class: MockRedis
- Inherits:
-
Object
show all
- Includes:
- UndefRedisMethods
- Defined in:
- lib/mock_redis/version.rb,
lib/mock_redis.rb,
lib/mock_redis/zset.rb,
lib/mock_redis/database.rb,
lib/mock_redis/assertions.rb,
lib/mock_redis/exceptions.rb,
lib/mock_redis/info_method.rb,
lib/mock_redis/set_methods.rb,
lib/mock_redis/sort_method.rb,
lib/mock_redis/hash_methods.rb,
lib/mock_redis/list_methods.rb,
lib/mock_redis/zset_methods.rb,
lib/mock_redis/expire_wrapper.rb,
lib/mock_redis/string_methods.rb,
lib/mock_redis/utility_methods.rb,
lib/mock_redis/indifferent_hash.rb,
lib/mock_redis/multi_db_wrapper.rb,
lib/mock_redis/pipelined_wrapper.rb,
lib/mock_redis/transaction_wrapper.rb,
lib/mock_redis/undef_redis_methods.rb
Overview
Defined Under Namespace
Modules: Assertions, HashMethods, InfoMethod, ListMethods, SetMethods, SortMethod, StringMethods, UndefRedisMethods, UtilityMethods, ZsetMethods
Classes: Database, ExpireWrapper, Future, FutureNotReady, IndifferentHash, MultiDbWrapper, PipelinedWrapper, TransactionWrapper, Zset
Constant Summary
collapse
- DEFAULTS =
{
:scheme => "redis",
:host => "127.0.0.1",
:port => 6379,
:path => nil,
:timeout => 5.0,
:password => nil,
:db => 0,
:time_class => Time,
}
- VERSION =
'0.13.2'
- WouldBlock =
Class.new(StandardError)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included
Constructor Details
#initialize(*args) ⇒ MockRedis
Returns a new instance of MockRedis.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
86
87
88
|
# File 'lib/mock_redis.rb', line 86
def method_missing(method, *args, &block)
@db.send(method, *args, &block)
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
14
15
16
|
# File 'lib/mock_redis.rb', line 14
def options
@options
end
|
Class Method Details
.connect(*args) ⇒ Object
27
28
29
|
# File 'lib/mock_redis.rb', line 27
def self.connect(*args)
new(*args)
end
|
Instance Method Details
#call(command, &block) ⇒ Object
46
47
48
|
# File 'lib/mock_redis.rb', line 46
def call(command, &block)
self.send(*command)
end
|
#client ⇒ Object
70
71
72
|
# File 'lib/mock_redis.rb', line 70
def client
self
end
|
#connect ⇒ Object
74
75
76
|
# File 'lib/mock_redis.rb', line 74
def connect
self
end
|
#db ⇒ Object
58
59
60
|
# File 'lib/mock_redis.rb', line 58
def db
self.options[:db]
end
|
#host ⇒ Object
50
51
52
|
# File 'lib/mock_redis.rb', line 50
def host
self.options[:host]
end
|
#id ⇒ Object
Also known as:
location
41
42
43
|
# File 'lib/mock_redis.rb', line 41
def id
"redis://#{self.host}:#{self.port}/#{self.db}"
end
|
#initialize_copy(source) ⇒ Object
90
91
92
93
|
# File 'lib/mock_redis.rb', line 90
def initialize_copy(source)
super
@db = @db.clone
end
|
#now ⇒ Object
62
63
64
|
# File 'lib/mock_redis.rb', line 62
def now
self.options[:time_class].now
end
|
#port ⇒ Object
54
55
56
|
# File 'lib/mock_redis.rb', line 54
def port
self.options[:port]
end
|
#reconnect ⇒ Object
78
79
80
|
# File 'lib/mock_redis.rb', line 78
def reconnect
self
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
82
83
84
|
# File 'lib/mock_redis.rb', line 82
def respond_to?(method, include_private=false)
super || @db.respond_to?(method, include_private)
end
|
#time_at(timestamp) ⇒ Object
66
67
68
|
# File 'lib/mock_redis.rb', line 66
def time_at(timestamp)
self.options[:time_class].at(timestamp)
end
|