mongoid 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Rakefile +1 -1
  2. data/VERSION +1 -1
  3. data/lib/mongoid.rb +2 -3
  4. data/lib/mongoid/associations.rb +5 -3
  5. data/lib/mongoid/associations/belongs_to_related.rb +6 -9
  6. data/lib/mongoid/associations/has_many.rb +2 -0
  7. data/lib/mongoid/associations/has_many_related.rb +10 -0
  8. data/lib/mongoid/attributes.rb +6 -1
  9. data/lib/mongoid/commands.rb +2 -10
  10. data/lib/mongoid/components.rb +11 -12
  11. data/lib/mongoid/contexts/enumerable.rb +21 -11
  12. data/lib/mongoid/contexts/mongo.rb +40 -1
  13. data/lib/mongoid/criteria.rb +3 -29
  14. data/lib/mongoid/criterion/inclusion.rb +2 -1
  15. data/lib/mongoid/document.rb +5 -6
  16. data/lib/mongoid/extensions.rb +10 -0
  17. data/lib/mongoid/extensions/big_decimal/conversions.rb +19 -0
  18. data/lib/mongoid/extensions/binary/conversions.rb +17 -0
  19. data/lib/mongoid/{caching.rb → extras.rb} +26 -3
  20. data/lib/mongoid/field.rb +20 -7
  21. data/lib/mongoid/finders.rb +10 -80
  22. data/mongoid.gemspec +15 -13
  23. data/spec/integration/mongoid/document_spec.rb +1 -1
  24. data/spec/models/person.rb +1 -0
  25. data/spec/unit/mongoid/associations/belongs_to_related_spec.rb +4 -0
  26. data/spec/unit/mongoid/associations/has_many_related_spec.rb +42 -13
  27. data/spec/unit/mongoid/associations/has_many_spec.rb +12 -7
  28. data/spec/unit/mongoid/associations_spec.rb +16 -0
  29. data/spec/unit/mongoid/attributes_spec.rb +23 -0
  30. data/spec/unit/mongoid/commands/destroy_spec.rb +3 -0
  31. data/spec/unit/mongoid/commands_spec.rb +4 -11
  32. data/spec/unit/mongoid/contexts/enumerable_spec.rb +16 -0
  33. data/spec/unit/mongoid/contexts/mongo_spec.rb +96 -0
  34. data/spec/unit/mongoid/criteria_spec.rb +11 -4
  35. data/spec/unit/mongoid/document_spec.rb +11 -0
  36. data/spec/unit/mongoid/extensions/big_decimal/conversions_spec.rb +22 -0
  37. data/spec/unit/mongoid/extensions/binary/conversions_spec.rb +22 -0
  38. data/spec/unit/mongoid/{enslavement_spec.rb → extras_spec.rb} +55 -2
  39. data/spec/unit/mongoid/field_spec.rb +62 -0
  40. data/spec/unit/mongoid/finders_spec.rb +36 -0
  41. metadata +69 -37
  42. data/HISTORY +0 -342
  43. data/lib/mongoid/enslavement.rb +0 -38
  44. data/spec/unit/mongoid/caching_spec.rb +0 -63
@@ -2,6 +2,42 @@ require "spec_helper"
2
2
 
3
3
  describe Mongoid::Field do
4
4
 
5
+ describe "#accessible?" do
6
+
7
+ context "when value is not set" do
8
+
9
+ before do
10
+ @field = Mongoid::Field.new(:name)
11
+ end
12
+
13
+ it "defaults to true" do
14
+ @field.accessible?.should be_true
15
+ end
16
+ end
17
+
18
+ context "when set to true" do
19
+
20
+ before do
21
+ @field = Mongoid::Field.new(:name, :accessible => true)
22
+ end
23
+
24
+ it "returns true" do
25
+ @field.accessible?.should be_true
26
+ end
27
+ end
28
+
29
+ context "when set to false" do
30
+
31
+ before do
32
+ @field = Mongoid::Field.new(:name, :accessible => false)
33
+ end
34
+
35
+ it "returns false" do
36
+ @field.accessible?.should be_false
37
+ end
38
+ end
39
+ end
40
+
5
41
  describe "#default" do
6
42
 
7
43
  before do
@@ -12,6 +48,32 @@ describe Mongoid::Field do
12
48
  @field.default.should == 0
13
49
  end
14
50
 
51
+ context "when the field is an array" do
52
+
53
+ before do
54
+ @field = Mongoid::Field.new(:vals, :type => Array, :default => [ "first" ])
55
+ end
56
+
57
+ it "dups the array" do
58
+ array = @field.default
59
+ array << "second"
60
+ @field.default.should == [ "first" ]
61
+ end
62
+ end
63
+
64
+ context "when the field is a hash" do
65
+
66
+ before do
67
+ @field = Mongoid::Field.new(:vals, :type => Hash, :default => { :key => "value" })
68
+ end
69
+
70
+ it "dups the hash" do
71
+ hash = @field.default
72
+ hash[:key_two] = "value2"
73
+ @field.default.should == { :key => "value" }
74
+ end
75
+ end
76
+
15
77
  end
16
78
 
17
79
  describe "#name" do
@@ -40,6 +40,24 @@ describe Mongoid::Finders do
40
40
 
41
41
  end
42
42
 
43
+ describe ".all_in" do
44
+
45
+ it "returns a new criteria with select conditions added" do
46
+ criteria = Person.all_in(:aliases => [ "Bond", "007" ])
47
+ criteria.selector.should == { :aliases => { "$all" => [ "Bond", "007" ] } }
48
+ end
49
+
50
+ end
51
+
52
+ describe ".any_in" do
53
+
54
+ it "returns a new criteria with select conditions added" do
55
+ criteria = Person.any_in(:aliases => [ "Bond", "007" ])
56
+ criteria.selector.should == { :aliases => { "$in" => [ "Bond", "007" ] } }
57
+ end
58
+
59
+ end
60
+
43
61
  describe ".count" do
44
62
 
45
63
  before do
@@ -65,6 +83,15 @@ describe Mongoid::Finders do
65
83
 
66
84
  end
67
85
 
86
+ describe ".excludes" do
87
+
88
+ it "returns a new criteria with select conditions added" do
89
+ criteria = Person.excludes(:title => "Sir")
90
+ criteria.selector.should == { :title => { "$ne" => "Sir" } }
91
+ end
92
+
93
+ end
94
+
68
95
  describe ".find" do
69
96
 
70
97
  before do
@@ -296,6 +323,15 @@ describe Mongoid::Finders do
296
323
 
297
324
  end
298
325
 
326
+ describe ".not_in" do
327
+
328
+ it "returns a new criteria with select conditions added" do
329
+ criteria = Person.not_in(:aliases => [ "Bond", "007" ])
330
+ criteria.selector.should == { :aliases => { "$nin" => [ "Bond", "007" ] } }
331
+ end
332
+
333
+ end
334
+
299
335
  describe ".paginate" do
300
336
 
301
337
  before do
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 2
8
+ - 9
9
+ version: 1.2.9
5
10
  platform: ruby
6
11
  authors:
7
12
  - Durran Jordan
@@ -9,69 +14,92 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-25 00:00:00 -05:00
17
+ date: 2010-03-09 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: activesupport
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - <=
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 3
30
+ - 5
23
31
  version: 2.3.5
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: mongo
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 18
44
+ - 3
33
45
  version: 0.18.3
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  - !ruby/object:Gem::Dependency
36
49
  name: durran-validatable
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
40
52
  requirements:
41
53
  - - ">="
42
54
  - !ruby/object:Gem::Version
55
+ segments:
56
+ - 2
57
+ - 0
58
+ - 1
43
59
  version: 2.0.1
44
- version:
60
+ type: :runtime
61
+ version_requirements: *id003
45
62
  - !ruby/object:Gem::Dependency
46
63
  name: will_paginate
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
50
66
  requirements:
51
67
  - - <
52
68
  - !ruby/object:Gem::Version
53
- version: 3.0.pre
54
- version:
69
+ segments:
70
+ - 2
71
+ - 9
72
+ version: "2.9"
73
+ type: :runtime
74
+ version_requirements: *id004
55
75
  - !ruby/object:Gem::Dependency
56
76
  name: rspec
57
- type: :development
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
60
79
  requirements:
61
80
  - - ">="
62
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 1
84
+ - 2
85
+ - 9
63
86
  version: 1.2.9
64
- version:
87
+ type: :development
88
+ version_requirements: *id005
65
89
  - !ruby/object:Gem::Dependency
66
90
  name: mocha
67
- type: :development
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
91
+ prerelease: false
92
+ requirement: &id006 !ruby/object:Gem::Requirement
70
93
  requirements:
71
94
  - - ">="
72
95
  - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
98
+ - 9
99
+ - 8
73
100
  version: 0.9.8
74
- version:
101
+ type: :development
102
+ version_requirements: *id006
75
103
  description:
76
104
  email: durran@gmail.com
77
105
  executables: []
@@ -83,7 +111,6 @@ extra_rdoc_files:
83
111
  files:
84
112
  - .gitignore
85
113
  - .watchr
86
- - HISTORY
87
114
  - MIT_LICENSE
88
115
  - README.rdoc
89
116
  - Rakefile
@@ -101,7 +128,6 @@ files:
101
128
  - lib/mongoid/associations/options.rb
102
129
  - lib/mongoid/associations/proxy.rb
103
130
  - lib/mongoid/attributes.rb
104
- - lib/mongoid/caching.rb
105
131
  - lib/mongoid/callbacks.rb
106
132
  - lib/mongoid/collection.rb
107
133
  - lib/mongoid/collections/cyclic_iterator.rb
@@ -131,7 +157,6 @@ files:
131
157
  - lib/mongoid/criterion/optional.rb
132
158
  - lib/mongoid/cursor.rb
133
159
  - lib/mongoid/document.rb
134
- - lib/mongoid/enslavement.rb
135
160
  - lib/mongoid/errors.rb
136
161
  - lib/mongoid/extensions.rb
137
162
  - lib/mongoid/extensions/array/accessors.rb
@@ -139,6 +164,8 @@ files:
139
164
  - lib/mongoid/extensions/array/assimilation.rb
140
165
  - lib/mongoid/extensions/array/conversions.rb
141
166
  - lib/mongoid/extensions/array/parentization.rb
167
+ - lib/mongoid/extensions/big_decimal/conversions.rb
168
+ - lib/mongoid/extensions/binary/conversions.rb
142
169
  - lib/mongoid/extensions/boolean/conversions.rb
143
170
  - lib/mongoid/extensions/date/conversions.rb
144
171
  - lib/mongoid/extensions/datetime/conversions.rb
@@ -156,6 +183,7 @@ files:
156
183
  - lib/mongoid/extensions/string/inflections.rb
157
184
  - lib/mongoid/extensions/symbol/inflections.rb
158
185
  - lib/mongoid/extensions/time/conversions.rb
186
+ - lib/mongoid/extras.rb
159
187
  - lib/mongoid/factory.rb
160
188
  - lib/mongoid/field.rb
161
189
  - lib/mongoid/fields.rb
@@ -224,7 +252,6 @@ files:
224
252
  - spec/unit/mongoid/associations/options_spec.rb
225
253
  - spec/unit/mongoid/associations_spec.rb
226
254
  - spec/unit/mongoid/attributes_spec.rb
227
- - spec/unit/mongoid/caching_spec.rb
228
255
  - spec/unit/mongoid/callbacks_spec.rb
229
256
  - spec/unit/mongoid/collection_spec.rb
230
257
  - spec/unit/mongoid/collections/cyclic_iterator_spec.rb
@@ -249,12 +276,13 @@ files:
249
276
  - spec/unit/mongoid/criterion/optional_spec.rb
250
277
  - spec/unit/mongoid/cursor_spec.rb
251
278
  - spec/unit/mongoid/document_spec.rb
252
- - spec/unit/mongoid/enslavement_spec.rb
253
279
  - spec/unit/mongoid/errors_spec.rb
254
280
  - spec/unit/mongoid/extensions/array/accessors_spec.rb
255
281
  - spec/unit/mongoid/extensions/array/assimilation_spec.rb
256
282
  - spec/unit/mongoid/extensions/array/conversions_spec.rb
257
283
  - spec/unit/mongoid/extensions/array/parentization_spec.rb
284
+ - spec/unit/mongoid/extensions/big_decimal/conversions_spec.rb
285
+ - spec/unit/mongoid/extensions/binary/conversions_spec.rb
258
286
  - spec/unit/mongoid/extensions/boolean/conversions_spec.rb
259
287
  - spec/unit/mongoid/extensions/date/conversions_spec.rb
260
288
  - spec/unit/mongoid/extensions/datetime/conversions_spec.rb
@@ -272,6 +300,7 @@ files:
272
300
  - spec/unit/mongoid/extensions/string/inflections_spec.rb
273
301
  - spec/unit/mongoid/extensions/symbol/inflections_spec.rb
274
302
  - spec/unit/mongoid/extensions/time/conversions_spec.rb
303
+ - spec/unit/mongoid/extras_spec.rb
275
304
  - spec/unit/mongoid/factory_spec.rb
276
305
  - spec/unit/mongoid/field_spec.rb
277
306
  - spec/unit/mongoid/fields_spec.rb
@@ -310,18 +339,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
310
339
  requirements:
311
340
  - - ">="
312
341
  - !ruby/object:Gem::Version
342
+ segments:
343
+ - 0
313
344
  version: "0"
314
- version:
315
345
  required_rubygems_version: !ruby/object:Gem::Requirement
316
346
  requirements:
317
347
  - - ">="
318
348
  - !ruby/object:Gem::Version
349
+ segments:
350
+ - 0
319
351
  version: "0"
320
- version:
321
352
  requirements: []
322
353
 
323
354
  rubyforge_project:
324
- rubygems_version: 1.3.5
355
+ rubygems_version: 1.3.6
325
356
  signing_key:
326
357
  specification_version: 3
327
358
  summary: ODM framework for MongoDB
@@ -366,7 +397,6 @@ test_files:
366
397
  - spec/unit/mongoid/associations/options_spec.rb
367
398
  - spec/unit/mongoid/associations_spec.rb
368
399
  - spec/unit/mongoid/attributes_spec.rb
369
- - spec/unit/mongoid/caching_spec.rb
370
400
  - spec/unit/mongoid/callbacks_spec.rb
371
401
  - spec/unit/mongoid/collection_spec.rb
372
402
  - spec/unit/mongoid/collections/cyclic_iterator_spec.rb
@@ -391,12 +421,13 @@ test_files:
391
421
  - spec/unit/mongoid/criterion/optional_spec.rb
392
422
  - spec/unit/mongoid/cursor_spec.rb
393
423
  - spec/unit/mongoid/document_spec.rb
394
- - spec/unit/mongoid/enslavement_spec.rb
395
424
  - spec/unit/mongoid/errors_spec.rb
396
425
  - spec/unit/mongoid/extensions/array/accessors_spec.rb
397
426
  - spec/unit/mongoid/extensions/array/assimilation_spec.rb
398
427
  - spec/unit/mongoid/extensions/array/conversions_spec.rb
399
428
  - spec/unit/mongoid/extensions/array/parentization_spec.rb
429
+ - spec/unit/mongoid/extensions/big_decimal/conversions_spec.rb
430
+ - spec/unit/mongoid/extensions/binary/conversions_spec.rb
400
431
  - spec/unit/mongoid/extensions/boolean/conversions_spec.rb
401
432
  - spec/unit/mongoid/extensions/date/conversions_spec.rb
402
433
  - spec/unit/mongoid/extensions/datetime/conversions_spec.rb
@@ -414,6 +445,7 @@ test_files:
414
445
  - spec/unit/mongoid/extensions/string/inflections_spec.rb
415
446
  - spec/unit/mongoid/extensions/symbol/inflections_spec.rb
416
447
  - spec/unit/mongoid/extensions/time/conversions_spec.rb
448
+ - spec/unit/mongoid/extras_spec.rb
417
449
  - spec/unit/mongoid/factory_spec.rb
418
450
  - spec/unit/mongoid/field_spec.rb
419
451
  - spec/unit/mongoid/fields_spec.rb
data/HISTORY DELETED
@@ -1,342 +0,0 @@
1
- === 1.2.0
2
- - Fixed composite key generation not to replace all
3
- special chars with dashes.
4
-
5
- - Memory optimizations, now wrapping the mongo cursor.
6
-
7
- - Fixed memoization on has_many_related assocations.
8
-
9
- - Fixed pagination on embedded associations
10
-
11
- - Fixed after_update callback not getting fired.
12
-
13
- - When a connection failure occurs, Mongoid tried to
14
- retry the operation up to a configurable time.
15
-
16
- - Mongoid now supports a configuration with a master
17
- and multiple read slaves. It will direct all writes
18
- to the master and all reads to the slaves. In the case
19
- of a write, subsequent reads will be directed to the
20
- master up to configurable number to try and counter
21
- the 2 second slave sync delay.
22
-
23
- - Fixed issue with criteria exclusion queries with ids.
24
-
25
- - Mongoid only executes a count when explicitly paginating.
26
-
27
- - Fixed Criteria offset to be a getter or setter
28
-
29
- - Added indexes to foreign keys on belongs_to_related
30
- associations.
31
-
32
- - General code refactorings/cleanup
33
-
34
- === 1.1.4
35
- - Refactorings in preparation for next feature push.
36
-
37
- - Associations may now have anonymous extensions.
38
-
39
- - Ruby 1.9 compatibility updates. (brainopia)
40
-
41
- - Document.to_json accepts options. (jsmestad)
42
-
43
- === 1.1.3
44
- - Nil can be passed into methods that set attributes.
45
-
46
- - Mongoid.config can now take a block.
47
-
48
- - Allow named_scopes and criteria class methods on
49
- has_many_related if related is a Mongoid document.
50
-
51
- - Document.find can now take an array of ids.
52
-
53
- === 1.1.2
54
- - Fixing issues with updates to parents.
55
-
56
- === 1.1.1
57
- - Document.create raises validations error, not no
58
- method error on self.errors (Rick Frankel)
59
-
60
- - Support default values that respond_to?(:call)
61
- (procs/lambda) (ahoward)
62
-
63
- - Added Mongoid.persist_in_safe_mode global config
64
- option.
65
-
66
- - Minor optimization: don't evaluate default procs
67
- if it's not needed (brainopia)
68
-
69
- === 1.1.0
70
- - Nil attributes no longer persist nil values to the
71
- database - the field will just not exist.
72
-
73
- - create! and save! will now properly raise an error
74
- when a database operation fails. This is handled
75
- by using :safe => true as an option to
76
- collection.save.
77
-
78
- - Setting blank numbers casts to nil.
79
-
80
- - Criteria and named scopes can now be used on has
81
- many relationships. They can be chained with each
82
- other off the association chain.
83
-
84
- - Mongoid can now determine if a document matches a
85
- mongodb selector without hitting the database via
86
- Document#matches?(selector).
87
-
88
- - Overall performance improvements in all areas.
89
-
90
- - Ruby 1.9 compatibility fixes.
91
-
92
- - Has many related now supports finding by id or
93
- by an optional :all, :first, :last with a
94
- conditions hash.
95
-
96
- === 1.0.6
97
-
98
- - Preventing the setting of empty values in attributes.
99
-
100
- - Better inspect formatting
101
-
102
- === 1.0.5
103
-
104
- - Has one and has many associations now set the parent
105
- object first before writing the attributes on
106
- #build and #create.
107
-
108
- === 1.0.4
109
- - Modified criteria to use the querying class
110
- when instantiating documents if there are no
111
- subclasses.
112
-
113
- - Floats that are empty strings or nil get
114
- defaulted to 0.0
115
-
116
- === 1.0.3
117
- - Small performance improvements on finders
118
-
119
- - Float.set allows setting of non-numeric string
120
- in order for validates_numericality_of to fail
121
- properly.
122
-
123
- === 1.0.2
124
- - Named scopes get added functionality:
125
-
126
- - named scopes can now be criteria objects.
127
-
128
- - named scoped can now be procs with criteria.
129
-
130
- - named scopes and class methods that return
131
- criteria can be chained with each other.
132
-
133
- - When calling save on an embedded document whose
134
- validation passes but the parent's validation
135
- fails, it will properly return false.
136
-
137
- === 1.0.1
138
- - Documents now have named_scopes similar to
139
- ActiveRecord named scopes. Please see rdoc or
140
- specs for examples.
141
-
142
- - Document#to_json properly works in all cases.
143
-
144
- - ActiveSupport calls for inflections have been
145
- moved into the String::Inflections module.
146
-
147
- - Updated dependency on Validatable to 2.0.1
148
-
149
- === 1.0.0
150
- - Validations cleanup: Only before_validation and
151
- after_validation callbacks are supported now.
152
-
153
- - Dynamic fields have reader and writer methods
154
- again, but only for instances where the dynamic
155
- attribute exists.
156
-
157
- - Lots of refactoring, mostly coverting common
158
- fucntionality into modules for the upcoming rails
159
- 2 and 3 gem split.
160
-
161
- === 0.12.0
162
- - Has one now works as expected:
163
-
164
- - Has one associations will return nil, instead
165
- of the proxy if the association has not been
166
- set.
167
-
168
- - Building/creating a has one is no longer handled
169
- by calling the Document#association#build() or create(),
170
- this is now handled by Document#build_name and
171
- Document#create_name where "name" is the name
172
- of the has one association.
173
-
174
- - Passing a _type attribute to the #build_name
175
- and #create_name methods will build/create
176
- objects of that type, useful for creating
177
- specific subclasses.
178
-
179
- - The existing #build and #create methods will be
180
- removed in the next release.
181
-
182
- - Removed all dynamic finders. If you need to have
183
- functionality similar to "find_or_(create|initialize)_by"
184
- you can use the 2 new finders:
185
-
186
- - Document.find_or_create_by(attributes): Will
187
- look for a document in the database with the
188
- supplied attributes, if found it will return the
189
- document otherwise will create a new one with
190
- the supplied attributes.
191
-
192
- - Document.find_or_initialize_by(attributes): Will
193
- look for a document in the database with the
194
- supplied attributes, if found it will return the
195
- document otherwise will instantiate a new one with
196
- the supplied attributes.
197
-
198
- - Fixed issue with empty hashes and arrays not getting
199
- set on document instantiation.
200
-
201
- === 0.11.9
202
- - Fixed issue with non-us time zones and formats
203
- parsing incorrectly.
204
-
205
- - Fixed error when specifying field restrictions
206
- in criteria and not providing the _type. It
207
- will now automaticall get added if it is not
208
- present.
209
-
210
- - Slight cleanup of delegated methods in Document.
211
-
212
- - Dynamic attributes no longer create setters and
213
- getters on the class. They can be accessed from
214
- the attributes hash directly. If they are used
215
- frequently it is preferrable to just add a field
216
- to the class manually.
217
-
218
- - Criteria#min no longer always returns 0.0.
219
-
220
- === 0.11.8
221
- - Added #min and #max to criteria which takes a
222
- single field argument.
223
-
224
- === 0.11.7
225
- - Added #sum to criteria which takes a single field
226
- to aggregate on. Example: Person.sum(:age) would
227
- return a float that was the sum of all people's
228
- ages in the db.
229
-
230
- - Fixed issue with queries from parent classes always
231
- casting the returned documents to the parent.
232
-
233
- - Fixed singleton require issue.
234
-
235
- - Group queries now run as db commands
236
-
237
- === 0.11.6
238
- - Allow namespaced documents to default with:
239
- "namespace_modelname"
240
-
241
- - Fixed indexing of _type field to only happen on root
242
- classes.
243
-
244
- - Fixed creation of empty collections for embedded documents.
245
-
246
- - Document.store_in now properly resets the collection
247
- if the collection had already been accessed.
248
-
249
- - Document.find(nil) now raises
250
- Mongoid::Errors::InvalidOptions
251
-
252
- === 0.11.5
253
- - Removed dependency on mongo_ext, since latest version
254
- was breaking on various operating systems.
255
- === 0.11.4
256
- - Fixed issue with dynamic fields: checking whether
257
- the document responded to the attribute's method
258
- should have checked the setter and not the getter
259
-
260
- - Fixed has_one associations not being able to be
261
- set to nil.
262
-
263
- === 0.11.3
264
- - Fixed issue with Document#save! not calling before
265
- and after create callbacks if document is new
266
-
267
- === 0.11.2
268
- - Fixing bug where has many and has one relational
269
- associations create method did not return the
270
- associated document
271
-
272
- === 0.11.1
273
- - Querying for classes that have subclasses will also
274
- return the subclasses as well, similar to
275
- ActiveRecord.
276
-
277
- - Adding configuration option allow_dynamic_fields. This
278
- defaults to true and if set to false will raise an
279
- error when trying to set an attribute on an object
280
- that does not have a corresponding field defined.
281
-
282
- === 0.11.0
283
- - Set the collection name to store a document in via:
284
- Document.store_in :collection_name
285
-
286
- - Initial inheritance support:
287
-
288
- - Documents and their associations can now have an
289
- infinite number of subclasses.
290
-
291
- - Has many and has one associations can build or
292
- create specific subclasses by providing an optional
293
- class as the last parameter to the #create and
294
- #build methods on the respective associations.
295
-
296
- - Querying for specific subclasses will only return
297
- those documents which were saved as that subclass,
298
- even though the hierarchy is stored in the same
299
- collection.
300
-
301
- - Deletion of subclass documents will only delete
302
- documents of that type, even though they all exist
303
- in the same collection. #delete_all and #destroy_all
304
- also support this behavoir.
305
-
306
- - Updated mongo and mongo_ext dependencies to 0.18.2
307
-
308
- - Fixed save on new documents to return true instead
309
- of the document itself.
310
-
311
- === 0.10.6
312
- - Fixed bug when trying to set empty strings on number
313
- fields. (TypeError: can't convert Fixnum into String)
314
-
315
- - Document.delete_all now drops the collection if
316
- conditions are empty or nil.
317
-
318
- === 0.10.5
319
-
320
- - Documents that are embedded not properly respond to
321
- Document#destroy and Document#delete.
322
-
323
- - Documents can now be saved sans validation with
324
- Document#save(false)
325
-
326
- === 0.10.4
327
-
328
- - Documents no longer inherit from Mongoid::Document.
329
- Please include Mongoid::Document in all your models now.
330
-
331
- - Config module added, you can now set one option:
332
- Mongoid.raise_not_found_error = (true|false)
333
-
334
- - When set to false, a Mongoid::Errors::DocumentNotFound
335
- will NOT get thrown when performing a Document.find(id)
336
- that does not return a document from the database.
337
- This defaults to true.
338
-
339
- - Mongoid::Document.collection_name macro added. You can
340
- now set the name of the database collection to persist to.
341
-
342
- - Mongoid::Criteria#select becomes Mongoid::Criteria#only