mongoid 0.9.3 → 0.9.4
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/README.textile +6 -1
- data/VERSION +1 -1
- data/lib/mongoid/criteria.rb +7 -3
- data/mongoid.gemspec +2 -2
- data/spec/unit/mongoid/criteria_spec.rb +28 -0
- metadata +2 -2
data/README.textile
CHANGED
@@ -70,6 +70,10 @@ Example of a simple domain model:
|
|
70
70
|
field :title
|
71
71
|
field :text
|
72
72
|
field :tags, :type => Array
|
73
|
+
relates_to_one :person
|
74
|
+
end
|
75
|
+
|
76
|
+
class Game < ActiveRecord::Base
|
73
77
|
end
|
74
78
|
</pre>
|
75
79
|
|
@@ -128,7 +132,8 @@ New School:
|
|
128
132
|
<pre>
|
129
133
|
Person.select(:first_name, :last_name).where(:title => "Sir").skip(10).limit(10).paginate
|
130
134
|
Person.select(:title).aggregate
|
131
|
-
|
135
|
+
Person.select(:first_name).order_by([[:first_name, :asc]])
|
136
|
+
Criteria.translate(:conditions => { :title => "Sir" })
|
132
137
|
</pre>
|
133
138
|
|
134
139
|
Chaining Scopes:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.4
|
data/lib/mongoid/criteria.rb
CHANGED
@@ -292,9 +292,13 @@ module Mongoid #:nodoc:
|
|
292
292
|
#
|
293
293
|
# Returns: <tt>Criteria</tt>
|
294
294
|
def method_missing(name, *args)
|
295
|
-
|
296
|
-
|
297
|
-
|
295
|
+
if @klass.respond_to?(name)
|
296
|
+
new_scope = @klass.send(name)
|
297
|
+
new_scope.merge(self)
|
298
|
+
return new_scope
|
299
|
+
else
|
300
|
+
return collect.send(name, *args)
|
301
|
+
end
|
298
302
|
end
|
299
303
|
|
300
304
|
# Adds a criterion to the +Criteria+ that specifies values where none
|
data/mongoid.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mongoid}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Durran Jordan"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-12-01}
|
13
13
|
s.email = %q{durran@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.textile"
|
@@ -457,6 +457,34 @@ describe Mongoid::Criteria do
|
|
457
457
|
|
458
458
|
end
|
459
459
|
|
460
|
+
context "when expecting behaviour of an array" do
|
461
|
+
|
462
|
+
before do
|
463
|
+
@array = mock
|
464
|
+
@document = mock
|
465
|
+
end
|
466
|
+
|
467
|
+
describe "#[]" do
|
468
|
+
|
469
|
+
it "collects the criteria and calls []" do
|
470
|
+
@criteria.expects(:collect).returns([@document])
|
471
|
+
@criteria[0].should == @document
|
472
|
+
end
|
473
|
+
|
474
|
+
end
|
475
|
+
|
476
|
+
describe "#rand" do
|
477
|
+
|
478
|
+
it "collects the criteria and call rand" do
|
479
|
+
@criteria.expects(:collect).returns(@array)
|
480
|
+
@array.expects(:send).with(:rand).returns(@document)
|
481
|
+
@criteria.rand
|
482
|
+
end
|
483
|
+
|
484
|
+
end
|
485
|
+
|
486
|
+
end
|
487
|
+
|
460
488
|
end
|
461
489
|
|
462
490
|
describe "#not_in" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Durran Jordan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-01 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|