Class: MockRedis
- Inherits:
-
Object
- Object
- MockRedis
- Includes:
- UndefRedisMethods
- Defined in:
- lib/mock_redis.rb,
lib/mock_redis/zset.rb,
lib/mock_redis/version.rb,
lib/mock_redis/database.rb,
lib/mock_redis/assertions.rb,
lib/mock_redis/exceptions.rb,
lib/mock_redis/set_methods.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/multi_db_wrapper.rb,
lib/mock_redis/transaction_wrapper.rb,
lib/mock_redis/undef_redis_methods.rb
Defined Under Namespace
Modules: Assertions, HashMethods, ListMethods, SetMethods, StringMethods, UndefRedisMethods, UtilityMethods, ZsetMethods Classes: Database, ExpireWrapper, MultiDbWrapper, TransactionWrapper, Zset
Constant Summary collapse
- VERSION =
"0.3.0"
- WouldBlock =
Class.new(StandardError)
Instance Method Summary collapse
-
#initialize(*args) ⇒ MockRedis
constructor
A new instance of MockRedis.
- #initialize_copy(source) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to?(method, include_private = false) ⇒ Boolean
Methods included from UndefRedisMethods
Constructor Details
#initialize(*args) ⇒ MockRedis
Returns a new instance of MockRedis.
13 14 15 16 17 18 |
# File 'lib/mock_redis.rb', line 13 def initialize(*args) @db = TransactionWrapper.new( ExpireWrapper.new( MultiDbWrapper.new( Database.new(*args)))) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
24 25 26 |
# File 'lib/mock_redis.rb', line 24 def method_missing(method, *args, &block) @db.send(method, *args, &block) end |
Instance Method Details
#initialize_copy(source) ⇒ Object
28 29 30 31 |
# File 'lib/mock_redis.rb', line 28 def initialize_copy(source) super @db = @db.clone end |
#respond_to?(method, include_private = false) ⇒ Boolean
20 21 22 |
# File 'lib/mock_redis.rb', line 20 def respond_to?(method, include_private=false) super || @db.respond_to?(method, include_private) end |