Skip to content
Browse files

Access to cursor directly from the class, redirect method calls to cu…

…rsor when available
  • Loading branch information...
1 parent ae7afeb commit 9292f9545d2dc8bd1dd6f410f7634fcff9ca29c6 Carlos Paramio committed
Showing with 37 additions and 32 deletions.
  1. +0 −21 Gemfile.lock
  2. +1 −1 LICENSE
  3. +22 −8 README.rdoc
  4. +12 −0 lib/mongo_odm/document/persistence.rb
  5. +1 −1 lib/mongo_odm/version.rb
  6. +1 −1 mongo_odm.gemspec
View
21 Gemfile.lock
@@ -1,20 +1,14 @@
GEM
remote: http://rubygems.org/
specs:
- ZenTest (4.4.2)
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activesupport (3.0.4)
- archive-tar-minitar (0.5.2)
- autotest (4.4.6)
- ZenTest (>= 4.4.1)
bson (1.2.2)
bson_ext (1.2.2)
builder (2.1.2)
- columnize (0.3.2)
- database_cleaner (0.6.3)
diff-lcs (1.1.2)
git (1.2.5)
i18n (0.5.0)
@@ -22,8 +16,6 @@ GEM
bundler (~> 1.0.0)
git (>= 1.2.5)
rake
- linecache19 (0.5.11)
- ruby_core_source (>= 0.1.4)
mongo (1.2.2)
bson (>= 1.2.2)
rake (0.8.7)
@@ -36,16 +28,6 @@ GEM
rspec-expectations (2.4.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.4.0)
- ruby-debug-base19 (0.11.24)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby_core_source (>= 0.1.4)
- ruby-debug19 (0.11.6)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby-debug-base19 (>= 0.11.19)
- ruby_core_source (0.1.4)
- archive-tar-minitar (>= 0.5.2)
tzinfo (0.3.24)
watchr (0.7)
yard (0.6.4)
@@ -56,14 +38,11 @@ PLATFORMS
DEPENDENCIES
activemodel (~> 3.0.4)
activesupport (~> 3.0.4)
- autotest
bson_ext (~> 1.2.2)
- database_cleaner
jeweler (~> 1.5.2)
mongo (~> 1.2.2)
rcov (~> 0.9.9)
rspec (= 2.4.0)
- ruby-debug19
tzinfo (~> 0.3.24)
watchr (~> 0.7)
yard (~> 0.6.4)
View
2 LICENSE
@@ -1,4 +1,4 @@
-Copyright 2010 Carlos Paramio
+Copyright 2010, 2011 Carlos Paramio
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
30 README.rdoc
@@ -384,6 +384,7 @@ All the validation methods defined in ActiveModel::Validations are included
Example:
class User
+ include MongoODM::Document
field :email
validates_presence_of :email
@@ -398,6 +399,7 @@ All the dirty object methods defined in ActiveModel::Dirty are included
Example:
class User
+ include MongoODM::Document
field :email
end
@@ -407,14 +409,26 @@ Example:
user.email_change # Returns [nil, "hello@h1labs.com"]
user.changes # Returns {"email" => [nil, "hello@h1labs.com"]}
+= Others
+
+Access to a cursor to the whole collection:
+
+ User.cursor
+
+Use cursor methods directly on the class:
+
+ User.has_next?
+ User.each{...}
+ User.next_document
+ User.rewind!
+ ...
+
= TODO
- * Support join of different concatenated find calls to a single criteria object
- * Add helpers to define attributes as referenced objects
* Allow to specify different database connections with each document definition
* Increase rspec coverage
* Document, document, document!
- * Create useful modules to make common operations easier (versioning, localization, etc)
+ * Create useful modules to make common operations easier (versioning, trees, etc)
= More
@@ -422,12 +436,12 @@ For now, take a look at the Mongo Ruby driver syntax:
http://api.mongodb.org/ruby/1.0.8/index.html
-= Copyright
+= Credits
-Copyright © 2010 Carlos Paramio. See LICENSE for details.
+Carlos Paramio, http://h1labs.com.
-= Credits
+See CONTRIBUTORS file for a list of contributions.
-Carlos Paramio
+= License
-http://h1labs.com
+See LICENSE file for details.
View
12 lib/mongo_odm/document/persistence.rb
@@ -98,6 +98,10 @@ def find(*args)
end
end
+ def cursor
+ @cursor ||= find.cursor
+ end
+
def destroy_all(*args)
documents = find(*args)
count = documents.count
@@ -110,6 +114,14 @@ def type_cast(value)
return value if value.class == self
new(value)
end
+
+ def method_missing(method_name, *args, &block)
+ if cursor.respond_to?(method_name)
+ cursor.send(method_name, *args, &block)
+ else
+ super
+ end
+ end
end
View
2 lib/mongo_odm/version.rb
@@ -2,6 +2,6 @@
module MongoODM
VERSION_MAJOR = "0"
VERSION_MINOR = "2"
- VERSION_BUILD = "7"
+ VERSION_BUILD = "8"
VERSION = "#{VERSION_MAJOR}.#{VERSION_MINOR}.#{VERSION_BUILD}"
end
View
2 mongo_odm.gemspec
@@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{mongo_odm}
- s.version = "0.2.7"
+ s.version = "0.2.8"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Carlos Paramio"]

0 comments on commit 9292f95

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