Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

hack: monkey patch symbol for nicer searches

  • Loading branch information...
commit bbc1948aaf78c7a43b6ce22aad865110542bd1bc 1 parent 45f220c
Aman Gupta authored

Showing 1 changed file with 19 additions and 2 deletions. Show diff stats Hide diff stats

  1. 21  rmongo.rb
21  rmongo.rb
@@ -133,6 +133,23 @@ def send(command_id, &cb)
133 133
   
134 134
 end
135 135
 
  136
+# XXX this is terrible, yes i know!
  137
+class Symbol
  138
+
  139
+  {
  140
+    :<  => :$lt,
  141
+    :<= => :$lte,
  142
+    :>  => :$gt,
  143
+    :>= => :$gte
  144
+  }.each do |func, key|
  145
+    class_eval %[
  146
+      def #{func} num
  147
+        { self => { :#{key} => num }}
  148
+      end
  149
+    ]
  150
+  end
  151
+end
  152
+
136 153
 EM.run{
137 154
   def log *args
138 155
     require 'pp'
@@ -167,8 +184,8 @@ def log *args
167 184
     log 'object with specific id', :found, results
168 185
   end
169 186
 
170  
-  mongo.find({ :n => { :$gt => 1 } }) do |results|
171  
-    log 'objects where n > 1', :found, results
  187
+  mongo.find(:n >= 1) do |results|
  188
+    log 'objects where n >= 1', :found, results
172 189
   end
173 190
   
174 191
   # mongo.close{ EM.stop_event_loop }

0 notes on commit bbc1948

Please sign in to comment.
Something went wrong with that request. Please try again.