mongoid 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ begin
15
15
  gem.add_dependency("activesupport", "<= 2.3.5")
16
16
  gem.add_dependency("mongo", ">= 0.18.2")
17
17
  gem.add_dependency("durran-validatable", ">= 2.0.1")
18
- gem.add_dependency("will_paginate", ">= 2.3.11")
18
+ gem.add_dependency("will_paginate", "< 3.0.pre")
19
19
 
20
20
  gem.add_development_dependency("rspec", ">= 1.2.9")
21
21
  gem.add_development_dependency("mocha", ">= 0.9.8")
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
data/lib/mongoid.rb CHANGED
@@ -24,7 +24,7 @@ require "rubygems"
24
24
  gem "activesupport", ">= 2.2.2", "<3.0.pre"
25
25
  gem "mongo", ">= 0.18.2"
26
26
  gem "durran-validatable", ">= 2.0.1"
27
- gem "will_paginate", ">= 2.3.11"
27
+ gem "will_paginate", ">= 2.3.11", "<3.0.pre"
28
28
 
29
29
  require "delegate"
30
30
  require "observer"
@@ -70,12 +70,23 @@ module Mongoid #:nodoc:
70
70
  self.selector == other.selector && self.options == other.options
71
71
  when Enumerable
72
72
  @collection ||= execute
73
- return (@collection.collect == other)
73
+ return (@collection.entries == other)
74
74
  else
75
75
  return false
76
76
  end
77
77
  end
78
78
 
79
+ # Returns true if the criteria is empty.
80
+ #
81
+ # Example:
82
+ #
83
+ # <tt>criteria.blank?</tt>
84
+ def blank?
85
+ count < 1
86
+ end
87
+
88
+ alias :empty? :blank?
89
+
79
90
  # Return or create the context in which this criteria should be executed.
80
91
  #
81
92
  # This will return an Enumerable context if the class is embedded,
@@ -110,8 +121,7 @@ module Mongoid #:nodoc:
110
121
  def each(&block)
111
122
  @collection ||= execute
112
123
  if block_given?
113
- docs = []
114
- @collection.each { |doc| docs << doc; yield doc }
124
+ @collection.each { |doc| yield doc }
115
125
  end
116
126
  self
117
127
  end
@@ -156,26 +166,6 @@ module Mongoid #:nodoc:
156
166
  # name: The name of the class method on the +Document+ to chain.
157
167
  # args: The arguments passed to the method.
158
168
  #
159
- # Example:
160
- #
161
- # class Person
162
- # include Mongoid::Document
163
- # field :title
164
- # field :terms, :type => Boolean, :default => false
165
- #
166
- # class << self
167
- # def knights
168
- # all(:conditions => { :title => "Sir" })
169
- # end
170
- #
171
- # def accepted
172
- # all(:conditions => { :terms => true })
173
- # end
174
- # end
175
- # end
176
- #
177
- # Person.accepted.knights #returns a merged criteria of the 2 scopes.
178
- #
179
169
  # Returns: <tt>Criteria</tt>
180
170
  def method_missing(name, *args)
181
171
  if @klass.respond_to?(name)
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 = "1.2.0"
8
+ s.version = "1.2.1"
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{2010-02-07}
12
+ s.date = %q{2010-02-08}
13
13
  s.email = %q{durran@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.rdoc"
@@ -345,14 +345,14 @@ Gem::Specification.new do |s|
345
345
  s.add_runtime_dependency(%q<activesupport>, ["<= 2.3.5"])
346
346
  s.add_runtime_dependency(%q<mongo>, [">= 0.18.2"])
347
347
  s.add_runtime_dependency(%q<durran-validatable>, [">= 2.0.1"])
348
- s.add_runtime_dependency(%q<will_paginate>, [">= 2.3.11"])
348
+ s.add_runtime_dependency(%q<will_paginate>, ["< 3.0.pre"])
349
349
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
350
350
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
351
351
  else
352
352
  s.add_dependency(%q<activesupport>, ["<= 2.3.5"])
353
353
  s.add_dependency(%q<mongo>, [">= 0.18.2"])
354
354
  s.add_dependency(%q<durran-validatable>, [">= 2.0.1"])
355
- s.add_dependency(%q<will_paginate>, [">= 2.3.11"])
355
+ s.add_dependency(%q<will_paginate>, ["< 3.0.pre"])
356
356
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
357
357
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
358
358
  end
@@ -360,7 +360,7 @@ Gem::Specification.new do |s|
360
360
  s.add_dependency(%q<activesupport>, ["<= 2.3.5"])
361
361
  s.add_dependency(%q<mongo>, [">= 0.18.2"])
362
362
  s.add_dependency(%q<durran-validatable>, [">= 2.0.1"])
363
- s.add_dependency(%q<will_paginate>, [">= 2.3.11"])
363
+ s.add_dependency(%q<will_paginate>, ["< 3.0.pre"])
364
364
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
365
365
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
366
366
  end
@@ -152,6 +152,36 @@ describe Mongoid::Criteria do
152
152
 
153
153
  end
154
154
 
155
+ describe "#blank?" do
156
+
157
+ before do
158
+ @context = stub.quacks_like(Mongoid::Contexts::Mongo.allocate)
159
+ @criteria.instance_variable_set(:@context, @context)
160
+ end
161
+
162
+ context "when the count is 0" do
163
+
164
+ before do
165
+ @context.expects(:count).returns(0)
166
+ end
167
+
168
+ it "returns true" do
169
+ @criteria.blank?.should be_true
170
+ end
171
+ end
172
+
173
+ context "when the count is greater than 0" do
174
+
175
+ before do
176
+ @context.expects(:count).returns(10)
177
+ end
178
+
179
+ it "returns false" do
180
+ @criteria.blank?.should be_false
181
+ end
182
+ end
183
+ end
184
+
155
185
  describe "#context" do
156
186
 
157
187
  context "when the context has been set" 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: 1.2.0
4
+ version: 1.2.1
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: 2010-02-07 00:00:00 -05:00
12
+ date: 2010-02-08 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -48,9 +48,9 @@ dependencies:
48
48
  version_requirement:
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - <
52
52
  - !ruby/object:Gem::Version
53
- version: 2.3.11
53
+ version: 3.0.pre
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec