Permalink
Browse files

Allow changing of the namespace at any point

  • Loading branch information...
1 parent 061f6c6 commit a7feec4f89e5d8e7c6abdfd9e91b6ba1a6a83937 @defunkt defunkt committed Jan 25, 2010
Showing with 16 additions and 0 deletions.
  1. +2 −0 lib/redis/namespace.rb
  2. +14 −0 spec/redis_spec.rb
@@ -66,6 +66,8 @@ class Namespace
"[]="
]
+ attr_accessor :namespace
+
def initialize(namespace, options = {})
@namespace = namespace
@redis = options[:redis]
View
@@ -43,4 +43,18 @@
@namespaced.mapped_mget('foo', 'bar').should == { 'foo' => '1000', 'bar' => '2000' }
@namespaced.mapped_mget('foo', 'baz', 'bar').should == {'foo'=>'1000', 'bar'=>'2000'}
end
+
+ it "can change its namespace" do
+ @namespaced['foo'].should == nil
+ @namespaced['foo'] = 'chris'
+ @namespaced['foo'].should == 'chris'
+
+ @namespaced.namespace.should == :ns
+ @namespaced.namespace = :spec
+ @namespaced.namespace.should == :spec
+
+ @namespaced['foo'].should == nil
+ @namespaced['foo'] = 'chris'
+ @namespaced['foo'].should == 'chris'
+ end
end

0 comments on commit a7feec4

Please sign in to comment.