Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

hack: monkey patch symbol for nicer searches

  • Loading branch information...
commit bbc1948aaf78c7a43b6ce22aad865110542bd1bc 1 parent 45f220c
@tmm1 authored
Showing with 19 additions and 2 deletions.
  1. +19 −2 rmongo.rb
View
21 rmongo.rb
@@ -133,6 +133,23 @@ def send(command_id, &cb)
end
+# XXX this is terrible, yes i know!
+class Symbol
+
+ {
+ :< => :$lt,
+ :<= => :$lte,
+ :> => :$gt,
+ :>= => :$gte
+ }.each do |func, key|
+ class_eval %[
+ def #{func} num
+ { self => { :#{key} => num }}
+ end
+ ]
+ end
+end
+
EM.run{
def log *args
require 'pp'
@@ -167,8 +184,8 @@ def log *args
log 'object with specific id', :found, results
end
- mongo.find({ :n => { :$gt => 1 } }) do |results|
- log 'objects where n > 1', :found, results
+ mongo.find(:n >= 1) do |results|
+ log 'objects where n >= 1', :found, results
end
# mongo.close{ EM.stop_event_loop }
Please sign in to comment.
Something went wrong with that request. Please try again.