mongo_doc 0.6.12 → 0.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.textile +1 -1
- data/VERSION +1 -1
- data/lib/mongo_doc/criteria.rb +1 -2
- data/lib/mongo_doc.rb +1 -1
- data/lib/mongoid/criterion/optional.rb +6 -2
- data/mongo_doc.gemspec +2 -2
- data/spec/criteria_spec.rb +8 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.textile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.13
|
data/lib/mongo_doc/criteria.rb
CHANGED
@@ -44,13 +44,12 @@ module MongoDoc
|
|
44
44
|
:where, :to => :criteria
|
45
45
|
|
46
46
|
class CriteriaWrapper < Mongoid::Criteria
|
47
|
-
%w(all and any_in cache enslave excludes extras fuse in limit not_in offset only order_by skip where).each do |method|
|
47
|
+
%w(all and any_in cache enslave excludes extras fuse id in limit not_in offset only order_by skip where).each do |method|
|
48
48
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
49
49
|
def #{method}_with_wrapping(*args, &block) # def and(*args, &block)
|
50
50
|
new_criteria = CriteriaWrapper.new(klass) # new_criteria = CriteriaWrapper.new(klass)
|
51
51
|
new_criteria.merge(self) # new_criteria.merge(criteria)
|
52
52
|
new_criteria.#{method}_without_wrapping(*args, &block) # new_criteria.and_without_wrapping(*args, &block)
|
53
|
-
new_criteria # new_criteria
|
54
53
|
end # end
|
55
54
|
|
56
55
|
alias_method_chain :#{method}, :wrapping
|
data/lib/mongo_doc.rb
CHANGED
@@ -76,8 +76,12 @@ module Mongoid #:nodoc:
|
|
76
76
|
# Returns: <tt>self</tt>
|
77
77
|
def id(*args)
|
78
78
|
ids = strings_to_object_ids(args.flatten)
|
79
|
-
|
80
|
-
|
79
|
+
if ids.size > 1
|
80
|
+
self.in(:_id => ids)
|
81
|
+
else
|
82
|
+
@selector[:_id] = ids.first
|
83
|
+
self
|
84
|
+
end
|
81
85
|
end
|
82
86
|
|
83
87
|
# Adds a criterion to the +Criteria+ that specifies the maximum number of
|
data/mongo_doc.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongo_doc}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.13"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Les Hill"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-25}
|
13
13
|
s.description = %q{ODM for MongoDB}
|
14
14
|
s.email = %q{leshill@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/criteria_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe MongoDoc::Criteria do
|
|
25
25
|
wrapper.klass.should == CriteriaTest
|
26
26
|
end
|
27
27
|
|
28
|
-
%w(all and any_in cache enslave excludes fuse in limit offset only order_by skip where).each do |wrapping_method|
|
28
|
+
%w(all and any_in cache enslave excludes fuse id in limit offset only order_by skip where).each do |wrapping_method|
|
29
29
|
it "#{wrapping_method} returns a new CriteriaWrapper" do
|
30
30
|
wrapper.send(wrapping_method).object_id.should_not == wrapper.object_id
|
31
31
|
end
|
@@ -39,6 +39,13 @@ describe MongoDoc::Criteria do
|
|
39
39
|
wrapper.not_in({}).object_id.should_not == wrapper.object_id
|
40
40
|
end
|
41
41
|
|
42
|
+
it "id with mutliple ids returns a new CriteriaWrapper with the id selector set" do
|
43
|
+
id1 = BSON::ObjectID.new
|
44
|
+
id2 = BSON::ObjectID.new
|
45
|
+
returned = wrapper.id(id1, id2)
|
46
|
+
returned.object_id.should_not == wrapper.object_id
|
47
|
+
returned.selector[:_id].should == {'$in' => [id1, id2]}
|
48
|
+
end
|
42
49
|
end
|
43
50
|
|
44
51
|
context "criteria delegates" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 13
|
10
|
+
version: 0.6.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Les Hill
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-25 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|