Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix namespace issues

  • Loading branch information...
commit 961ceec500201f654b5144c2c00304187984dfd3 1 parent bc68c78
@tmm1 authored
Showing with 20 additions and 10 deletions.
  1. +20 −10 rmongo.rb
View
30 rmongo.rb
@@ -21,17 +21,24 @@ def initialize opts = {}
end
def namespace ns = nil
- begin
- old_ns = @namespace
- @namespace = ns
- yield
- ensure
- @namespace = old_ns
- end if ns
+ callback{
+ begin
+ old_ns = @namespace
+ @namespace = ns
+ yield
+ ensure
+ @namespace = old_ns
+ end if ns
+ }
@namespace
end
- attr_writer :namespace
+
+ def namespace= ns
+ callback{
+ @namespace = ns
+ }
+ end
# EM hooks
@@ -270,13 +277,16 @@ def desc
end
# sorting # XXX why doesn't this work
- mongo.find(:n > 0, :n.desc) do |results|
+ mongo.find({}, :n.desc) do |results|
end
# switch to editors namespace
mongo.namespace = 'default.editors'
+ # delete all rows
+ mongo.remove({})
+
# insert editors with platforms supported tags
mongo.insert(:_id => '000000000000000000000101', :name => :textmate, :platform => [:osx])
mongo.insert(:_id => '000000000000000000000102', :name => :vim, :platform => [:osx, :linux])
@@ -293,7 +303,7 @@ def desc
mongo.insert(:name => 'platforms', :ns => 'default.editors', :key => { :platform => true })
end
- # find objects with linux tag
+ # find objects with linux tag # XXX how can i find an object with two tags?
mongo.find(:platform => :linux) do |results|
end
Please sign in to comment.
Something went wrong with that request. Please try again.