Permalink
Browse files

Client#namespace can take a new namespace, or a block to execute with…

…in a namespace
  • Loading branch information...
tmm1 committed Aug 2, 2008
1 parent 79ee4ff commit c74901c1a9f78ad907507185c7b228c8b1fa485a
Showing with 13 additions and 1 deletion.
  1. +13 −1 rmongo.rb
View
@@ -18,7 +18,19 @@ def initialize opts = {}
raise Error, 'could not connect to server'
}
end
- attr_accessor :namespace
+
+ def namespace ns = nil
+ begin
+ old_ns = @namespace
+ @namespace = ns
+ yield
+ ensure
+ @namespace = old_ns
+ end if ns
+
+ @namespace
+ end
+ attr_writer :namespace
# EM hooks

0 comments on commit c74901c

Please sign in to comment.