mongoid 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- Criteria.translate(:conditions => { :title => "Sir" }).execute
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.3
1
+ 0.9.4
@@ -292,9 +292,13 @@ module Mongoid #:nodoc:
292
292
  #
293
293
  # Returns: <tt>Criteria</tt>
294
294
  def method_missing(name, *args)
295
- new_scope = @klass.send(name)
296
- new_scope.merge(self)
297
- new_scope
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
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid}
8
- s.version = "0.9.3"
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-11-30}
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.3
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-11-30 00:00:00 -05:00
12
+ date: 2009-12-01 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency