Permalink
Browse files

whitespace cleanup

  • Loading branch information...
1 parent 04b3c14 commit 9dca4b264a5514336b8b937729aa60e3b6c4c4e5 @jsmestad jsmestad committed May 24, 2011
Showing with 16 additions and 16 deletions.
  1. +11 −11 lib/mongomatic/cursor.rb
  2. +5 −5 test/test_typed_fields.rb
View
@@ -8,9 +8,9 @@ module Mongomatic
# User.find({"zip" => 94107}).count
class Cursor
include Enumerable
-
+
attr_accessor :mongo_cursor
-
+
def initialize(obj_class, mongo_cursor)
@obj_class = obj_class
@mongo_cursor = mongo_cursor
@@ -19,42 +19,42 @@ def initialize(obj_class, mongo_cursor)
def method_missing(name, *args)
@mongo_cursor.send name, *args
end
-
+
# Is the cursor empty? This method is much more efficient than doing cursor.count == 0
def empty?
@mongo_cursor.has_next? == false
end
-
+
def next_document
if doc = @mongo_cursor.next_document
@obj_class.new(doc, false)
end
end
-
+
alias :next :next_document
-
+
def each
@mongo_cursor.each do |doc|
yield(@obj_class.new(doc, false))
end
end
-
+
def current_limit
@mongo_cursor.limit
end
-
+
def limit(number_to_return)
@mongo_cursor.limit(number_to_return); self
end
-
+
def current_skip
@mongo_cursor.skip
end
-
+
def skip(number_to_skip)
@mongo_cursor.skip(number_to_skip); self
end
-
+
def sort(key_or_list, direction = nil)
@mongo_cursor.sort(key_or_list, direction); self
end
View
@@ -16,7 +16,7 @@ def test_raising_error_on_invalid_type
assert_equal true, r.valid?
assert_equal "(800) 123 456 789", r["manufacturer"]["phone"]
end
-
+
def test_cast_string
r = Rig.new
r["manufacturer"] = {}
@@ -25,23 +25,23 @@ def test_cast_string
assert r.valid?
assert_equal ["Wings","Parachuting","Company"].to_s, r["manufacturer"]["name"]
end
-
+
def test_cast_number
r = Rig.new
r["age"] = "4"
assert_equal "4", r["age"]
assert r.valid?
assert_equal 4, r["age"]
end
-
+
def test_cast_float
r = Rig.new
r["waist_measurement"] = "34.3"
assert_equal "34.3", r["waist_measurement"]
assert r.valid?
assert_equal 34.3, r["waist_measurement"]
end
-
+
def test_cast_object_id
r = Rig.new
assert r.insert
@@ -50,4 +50,4 @@ def test_cast_object_id
r2.insert
assert_equal "BSON::ObjectId", r2["friends_rig_id"].class.to_s
end
-end
+end

0 comments on commit 9dca4b2

Please sign in to comment.