Permalink
Browse files

...

  • Loading branch information...
1 parent 94e0685 commit 03606fcb2a390993913c5fb3c18353d0a989f14a Adrian Madrid committed Aug 1, 2008
Showing with 7 additions and 19 deletions.
  1. +7 −19 rmongo.rb
View
@@ -65,7 +65,7 @@ def unbind
# to sort: { query : { ... } , orderby : { ... } }
def find obj, &cb
- data = send(2004) do |buf|
+ send(2004) do |buf|
# body
buf.write :int, reserved = 0,
:cstring, namespace = 'default.test',
@@ -77,30 +77,20 @@ def find obj, &cb
end
(@responses ||= {})[ @id ] = cb if cb
-
- callback{
- send_data [ data.size + 4 ].pack('i')
- send_data data
- }
end
def insert obj
- data = send(2002) do |buf|
+ send(2002) do |buf|
# body
buf.write :int, reserved = 0,
:cstring, namespace = 'default.test'
# bson
buf.write :bson, obj
end
-
- callback{
- send_data [ data.size + 4 ].pack('i')
- send_data data
- }
end
def remove obj
- data = send(2006) do |buf|
+ send(2006) do |buf|
# body
buf.write :int, reserved = 0,
:cstring, namespace = 'default.test',
@@ -109,11 +99,6 @@ def remove obj
# bson
buf.write :bson, obj
end
-
- callback{
- send_data [ data.size + 4 ].pack('i')
- send_data data
- }
end
# connection
@@ -139,7 +124,10 @@ def send(command_id, &cb)
:int, response = 0,
:int, operation = command_id
yield buf
- buf.data
+ callback{
+ send_data [ buf.size + 4 ].pack('i')
+ send_data buf.data
+ }
end
end

0 comments on commit 03606fc

Please sign in to comment.