mongo_mapper 0.8.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/UPGRADES +10 -0
  2. data/bin/mmconsole +0 -1
  3. data/examples/identity_map/automatic.rb +1 -7
  4. data/examples/plugins.rb +9 -9
  5. data/examples/safe.rb +43 -0
  6. data/lib/mongo_mapper.rb +46 -33
  7. data/lib/mongo_mapper/document.rb +33 -32
  8. data/lib/mongo_mapper/embedded_document.rb +22 -22
  9. data/lib/mongo_mapper/locale/en.yml +5 -0
  10. data/lib/mongo_mapper/middleware/identity_map.rb +16 -0
  11. data/lib/mongo_mapper/plugins.rb +16 -3
  12. data/lib/mongo_mapper/plugins/accessible.rb +2 -0
  13. data/lib/mongo_mapper/plugins/active_model.rb +18 -0
  14. data/lib/mongo_mapper/plugins/associations.rb +37 -42
  15. data/lib/mongo_mapper/plugins/associations/base.rb +14 -50
  16. data/lib/mongo_mapper/plugins/associations/belongs_to_association.rb +58 -0
  17. data/lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb +6 -1
  18. data/lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb +30 -2
  19. data/lib/mongo_mapper/plugins/associations/embedded_collection.rb +4 -0
  20. data/lib/mongo_mapper/plugins/associations/in_array_proxy.rb +12 -6
  21. data/lib/mongo_mapper/plugins/associations/many_association.rb +67 -0
  22. data/lib/mongo_mapper/plugins/associations/many_documents_proxy.rb +5 -5
  23. data/lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb +1 -1
  24. data/lib/mongo_mapper/plugins/associations/one_association.rb +20 -0
  25. data/lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb +5 -0
  26. data/lib/mongo_mapper/plugins/associations/one_proxy.rb +7 -7
  27. data/lib/mongo_mapper/plugins/associations/proxy.rb +2 -2
  28. data/lib/mongo_mapper/plugins/caching.rb +3 -1
  29. data/lib/mongo_mapper/plugins/callbacks.rb +12 -221
  30. data/lib/mongo_mapper/plugins/clone.rb +3 -1
  31. data/lib/mongo_mapper/plugins/dirty.rb +38 -91
  32. data/lib/mongo_mapper/plugins/document.rb +4 -2
  33. data/lib/mongo_mapper/plugins/dynamic_querying.rb +2 -0
  34. data/lib/mongo_mapper/plugins/embedded_callbacks.rb +43 -0
  35. data/lib/mongo_mapper/plugins/embedded_document.rb +16 -9
  36. data/lib/mongo_mapper/plugins/equality.rb +2 -0
  37. data/lib/mongo_mapper/plugins/identity_map.rb +4 -2
  38. data/lib/mongo_mapper/plugins/indexes.rb +2 -0
  39. data/lib/mongo_mapper/plugins/inspect.rb +3 -1
  40. data/lib/mongo_mapper/plugins/keys.rb +28 -22
  41. data/lib/mongo_mapper/plugins/keys/key.rb +12 -6
  42. data/lib/mongo_mapper/plugins/logger.rb +2 -0
  43. data/lib/mongo_mapper/plugins/modifiers.rb +3 -1
  44. data/lib/mongo_mapper/plugins/pagination.rb +2 -0
  45. data/lib/mongo_mapper/plugins/persistence.rb +2 -0
  46. data/lib/mongo_mapper/plugins/protected.rb +2 -0
  47. data/lib/mongo_mapper/plugins/querying.rb +5 -4
  48. data/lib/mongo_mapper/plugins/rails.rb +3 -5
  49. data/lib/mongo_mapper/plugins/safe.rb +2 -0
  50. data/lib/mongo_mapper/plugins/sci.rb +2 -0
  51. data/lib/mongo_mapper/plugins/scopes.rb +2 -0
  52. data/lib/mongo_mapper/plugins/serialization.rb +67 -46
  53. data/lib/mongo_mapper/plugins/timestamps.rb +3 -1
  54. data/lib/mongo_mapper/plugins/userstamps.rb +2 -0
  55. data/lib/mongo_mapper/plugins/validations.rb +40 -24
  56. data/lib/mongo_mapper/railtie.rb +49 -0
  57. data/lib/mongo_mapper/railtie/database.rake +60 -0
  58. data/lib/mongo_mapper/support/descendant_appends.rb +11 -11
  59. data/lib/mongo_mapper/translation.rb +10 -0
  60. data/lib/mongo_mapper/version.rb +1 -1
  61. data/lib/rails/generators/mongo_mapper/config/config_generator.rb +24 -0
  62. data/lib/rails/generators/mongo_mapper/config/templates/mongo.yml +18 -0
  63. data/lib/rails/generators/mongo_mapper/model/model_generator.rb +23 -0
  64. data/lib/rails/generators/mongo_mapper/model/templates/model.rb +11 -0
  65. data/test/functional/associations/test_belongs_to_polymorphic_proxy.rb +1 -0
  66. data/test/functional/associations/test_belongs_to_proxy.rb +131 -1
  67. data/test/functional/associations/test_in_array_proxy.rb +30 -0
  68. data/test/functional/associations/test_many_documents_proxy.rb +30 -2
  69. data/test/functional/associations/test_many_embedded_proxy.rb +33 -0
  70. data/test/functional/associations/test_many_polymorphic_proxy.rb +1 -0
  71. data/test/functional/associations/test_one_embedded_proxy.rb +21 -2
  72. data/test/functional/associations/test_one_proxy.rb +49 -9
  73. data/test/functional/test_associations.rb +2 -0
  74. data/test/functional/test_caching.rb +3 -2
  75. data/test/functional/test_callbacks.rb +25 -18
  76. data/test/functional/test_dirty.rb +123 -1
  77. data/test/functional/test_document.rb +26 -2
  78. data/test/functional/test_embedded_document.rb +68 -2
  79. data/test/functional/test_identity_map.rb +3 -4
  80. data/test/functional/test_querying.rb +11 -0
  81. data/test/functional/test_userstamps.rb +2 -2
  82. data/test/functional/test_validations.rb +31 -29
  83. data/test/models.rb +10 -0
  84. data/test/test_active_model_lint.rb +1 -1
  85. data/test/test_helper.rb +9 -10
  86. data/test/unit/associations/test_base.rb +24 -100
  87. data/test/unit/associations/test_belongs_to_association.rb +29 -0
  88. data/test/unit/associations/test_many_association.rb +63 -0
  89. data/test/unit/associations/test_one_association.rb +18 -0
  90. data/test/unit/serializers/test_json_serializer.rb +0 -1
  91. data/test/unit/test_descendant_appends.rb +8 -16
  92. data/test/unit/test_document.rb +4 -9
  93. data/test/unit/test_dynamic_finder.rb +1 -1
  94. data/test/unit/test_embedded_document.rb +51 -18
  95. data/test/unit/test_identity_map_middleware.rb +34 -0
  96. data/test/unit/test_inspect.rb +22 -0
  97. data/test/unit/test_key.rb +21 -1
  98. data/test/unit/test_keys.rb +0 -2
  99. data/test/unit/test_plugins.rb +106 -20
  100. data/test/unit/test_rails.rb +8 -8
  101. data/test/unit/test_serialization.rb +116 -1
  102. data/test/unit/test_translation.rb +27 -0
  103. data/test/unit/test_validations.rb +66 -81
  104. metadata +103 -43
  105. data/examples/identity_map/middleware.rb +0 -14
  106. data/lib/mongo_mapper/plugins/descendants.rb +0 -17
  107. data/rails/init.rb +0 -19
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_mapper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 8
9
- - 6
10
- version: 0.8.6
8
+ - 9
9
+ - 0
10
+ version: 0.9.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Nunemaker
@@ -15,44 +15,42 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-11 00:00:00 -04:00
18
+ date: 2011-04-12 00:00:00 -04:00
19
19
  default_executable: mmconsole
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: activesupport
23
- prerelease: false
24
22
  requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
27
- - - ">="
25
+ - - ~>
28
26
  - !ruby/object:Gem::Version
29
- hash: 11
27
+ hash: 7
30
28
  segments:
31
- - 2
32
29
  - 3
33
- - 4
34
- version: 2.3.4
30
+ - 0
31
+ - 0
32
+ version: 3.0.0
33
+ name: activemodel
34
+ prerelease: false
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: jnunemaker-validatable
39
- prerelease: false
40
38
  requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - ~>
44
42
  - !ruby/object:Gem::Version
45
- hash: 63
43
+ hash: 7
46
44
  segments:
47
- - 1
48
- - 8
49
- - 4
50
- version: 1.8.4
45
+ - 3
46
+ - 0
47
+ - 0
48
+ version: 3.0.0
49
+ name: activesupport
50
+ prerelease: false
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: plucky
55
- prerelease: false
56
54
  requirement: &id003 !ruby/object:Gem::Requirement
57
55
  none: false
58
56
  requirements:
@@ -64,11 +62,11 @@ dependencies:
64
62
  - 3
65
63
  - 6
66
64
  version: 0.3.6
65
+ name: plucky
66
+ prerelease: false
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
70
- name: json
71
- prerelease: false
72
70
  requirement: &id004 !ruby/object:Gem::Requirement
73
71
  none: false
74
72
  requirements:
@@ -78,11 +76,11 @@ dependencies:
78
76
  segments:
79
77
  - 0
80
78
  version: "0"
79
+ name: rake
80
+ prerelease: false
81
81
  type: :development
82
82
  version_requirements: *id004
83
83
  - !ruby/object:Gem::Dependency
84
- name: log_buddy
85
- prerelease: false
86
84
  requirement: &id005 !ruby/object:Gem::Requirement
87
85
  none: false
88
86
  requirements:
@@ -92,12 +90,40 @@ dependencies:
92
90
  segments:
93
91
  - 0
94
92
  version: "0"
93
+ name: tzinfo
94
+ prerelease: false
95
95
  type: :development
96
96
  version_requirements: *id005
97
97
  - !ruby/object:Gem::Dependency
98
- name: jnunemaker-matchy
99
- prerelease: false
100
98
  requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ name: json
108
+ prerelease: false
109
+ type: :development
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ requirement: &id007 !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ name: log_buddy
122
+ prerelease: false
123
+ type: :development
124
+ version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ requirement: &id008 !ruby/object:Gem::Requirement
101
127
  none: false
102
128
  requirements:
103
129
  - - ~>
@@ -108,12 +134,12 @@ dependencies:
108
134
  - 4
109
135
  - 0
110
136
  version: 0.4.0
137
+ name: jnunemaker-matchy
138
+ prerelease: false
111
139
  type: :development
112
- version_requirements: *id006
140
+ version_requirements: *id008
113
141
  - !ruby/object:Gem::Dependency
114
- name: shoulda
115
- prerelease: false
116
- requirement: &id007 !ruby/object:Gem::Requirement
142
+ requirement: &id009 !ruby/object:Gem::Requirement
117
143
  none: false
118
144
  requirements:
119
145
  - - ~>
@@ -123,12 +149,12 @@ dependencies:
123
149
  - 2
124
150
  - 11
125
151
  version: "2.11"
152
+ name: shoulda
153
+ prerelease: false
126
154
  type: :development
127
- version_requirements: *id007
155
+ version_requirements: *id009
128
156
  - !ruby/object:Gem::Dependency
129
- name: timecop
130
- prerelease: false
131
- requirement: &id008 !ruby/object:Gem::Requirement
157
+ requirement: &id010 !ruby/object:Gem::Requirement
132
158
  none: false
133
159
  requirements:
134
160
  - - ~>
@@ -139,12 +165,12 @@ dependencies:
139
165
  - 3
140
166
  - 1
141
167
  version: 0.3.1
168
+ name: timecop
169
+ prerelease: false
142
170
  type: :development
143
- version_requirements: *id008
171
+ version_requirements: *id010
144
172
  - !ruby/object:Gem::Dependency
145
- name: mocha
146
- prerelease: false
147
- requirement: &id009 !ruby/object:Gem::Requirement
173
+ requirement: &id011 !ruby/object:Gem::Requirement
148
174
  none: false
149
175
  requirements:
150
176
  - - ~>
@@ -155,8 +181,24 @@ dependencies:
155
181
  - 9
156
182
  - 8
157
183
  version: 0.9.8
184
+ name: mocha
185
+ prerelease: false
158
186
  type: :development
159
- version_requirements: *id009
187
+ version_requirements: *id011
188
+ - !ruby/object:Gem::Dependency
189
+ requirement: &id012 !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ hash: 3
195
+ segments:
196
+ - 0
197
+ version: "0"
198
+ name: rack-test
199
+ prerelease: false
200
+ type: :development
201
+ version_requirements: *id012
160
202
  description:
161
203
  email:
162
204
  - nunemaker@gmail.com
@@ -173,12 +215,12 @@ files:
173
215
  - examples/cache_key.rb
174
216
  - examples/custom_types.rb
175
217
  - examples/identity_map/automatic.rb
176
- - examples/identity_map/middleware.rb
177
218
  - examples/identity_map.rb
178
219
  - examples/keys.rb
179
220
  - examples/modifiers/set.rb
180
221
  - examples/plugins.rb
181
222
  - examples/querying.rb
223
+ - examples/safe.rb
182
224
  - examples/scopes.rb
183
225
  - examples/validating/embedded_docs.rb
184
226
  - lib/mongo_mapper/connection.rb
@@ -199,18 +241,24 @@ files:
199
241
  - lib/mongo_mapper/extensions/set.rb
200
242
  - lib/mongo_mapper/extensions/string.rb
201
243
  - lib/mongo_mapper/extensions/time.rb
244
+ - lib/mongo_mapper/locale/en.yml
245
+ - lib/mongo_mapper/middleware/identity_map.rb
202
246
  - lib/mongo_mapper/plugins/accessible.rb
247
+ - lib/mongo_mapper/plugins/active_model.rb
203
248
  - lib/mongo_mapper/plugins/associations/base.rb
249
+ - lib/mongo_mapper/plugins/associations/belongs_to_association.rb
204
250
  - lib/mongo_mapper/plugins/associations/belongs_to_polymorphic_proxy.rb
205
251
  - lib/mongo_mapper/plugins/associations/belongs_to_proxy.rb
206
252
  - lib/mongo_mapper/plugins/associations/collection.rb
207
253
  - lib/mongo_mapper/plugins/associations/embedded_collection.rb
208
254
  - lib/mongo_mapper/plugins/associations/in_array_proxy.rb
255
+ - lib/mongo_mapper/plugins/associations/many_association.rb
209
256
  - lib/mongo_mapper/plugins/associations/many_documents_as_proxy.rb
210
257
  - lib/mongo_mapper/plugins/associations/many_documents_proxy.rb
211
258
  - lib/mongo_mapper/plugins/associations/many_embedded_polymorphic_proxy.rb
212
259
  - lib/mongo_mapper/plugins/associations/many_embedded_proxy.rb
213
260
  - lib/mongo_mapper/plugins/associations/many_polymorphic_proxy.rb
261
+ - lib/mongo_mapper/plugins/associations/one_association.rb
214
262
  - lib/mongo_mapper/plugins/associations/one_embedded_proxy.rb
215
263
  - lib/mongo_mapper/plugins/associations/one_proxy.rb
216
264
  - lib/mongo_mapper/plugins/associations/proxy.rb
@@ -218,11 +266,11 @@ files:
218
266
  - lib/mongo_mapper/plugins/caching.rb
219
267
  - lib/mongo_mapper/plugins/callbacks.rb
220
268
  - lib/mongo_mapper/plugins/clone.rb
221
- - lib/mongo_mapper/plugins/descendants.rb
222
269
  - lib/mongo_mapper/plugins/dirty.rb
223
270
  - lib/mongo_mapper/plugins/document.rb
224
271
  - lib/mongo_mapper/plugins/dynamic_querying/dynamic_finder.rb
225
272
  - lib/mongo_mapper/plugins/dynamic_querying.rb
273
+ - lib/mongo_mapper/plugins/embedded_callbacks.rb
226
274
  - lib/mongo_mapper/plugins/embedded_document.rb
227
275
  - lib/mongo_mapper/plugins/equality.rb
228
276
  - lib/mongo_mapper/plugins/identity_map.rb
@@ -247,10 +295,16 @@ files:
247
295
  - lib/mongo_mapper/plugins/userstamps.rb
248
296
  - lib/mongo_mapper/plugins/validations.rb
249
297
  - lib/mongo_mapper/plugins.rb
298
+ - lib/mongo_mapper/railtie/database.rake
299
+ - lib/mongo_mapper/railtie.rb
250
300
  - lib/mongo_mapper/support/descendant_appends.rb
301
+ - lib/mongo_mapper/translation.rb
251
302
  - lib/mongo_mapper/version.rb
252
303
  - lib/mongo_mapper.rb
253
- - rails/init.rb
304
+ - lib/rails/generators/mongo_mapper/config/config_generator.rb
305
+ - lib/rails/generators/mongo_mapper/config/templates/mongo.yml
306
+ - lib/rails/generators/mongo_mapper/model/model_generator.rb
307
+ - lib/rails/generators/mongo_mapper/model/templates/model.rb
254
308
  - test/_NOTE_ON_TESTING
255
309
  - test/functional/associations/test_belongs_to_polymorphic_proxy.rb
256
310
  - test/functional/associations/test_belongs_to_proxy.rb
@@ -289,6 +343,9 @@ files:
289
343
  - test/test_active_model_lint.rb
290
344
  - test/test_helper.rb
291
345
  - test/unit/associations/test_base.rb
346
+ - test/unit/associations/test_belongs_to_association.rb
347
+ - test/unit/associations/test_many_association.rb
348
+ - test/unit/associations/test_one_association.rb
292
349
  - test/unit/associations/test_proxy.rb
293
350
  - test/unit/serializers/test_json_serializer.rb
294
351
  - test/unit/test_clone.rb
@@ -297,6 +354,8 @@ files:
297
354
  - test/unit/test_dynamic_finder.rb
298
355
  - test/unit/test_embedded_document.rb
299
356
  - test/unit/test_extensions.rb
357
+ - test/unit/test_identity_map_middleware.rb
358
+ - test/unit/test_inspect.rb
300
359
  - test/unit/test_key.rb
301
360
  - test/unit/test_keys.rb
302
361
  - test/unit/test_mongo_mapper.rb
@@ -306,6 +365,7 @@ files:
306
365
  - test/unit/test_rails_compatibility.rb
307
366
  - test/unit/test_serialization.rb
308
367
  - test/unit/test_time_zones.rb
368
+ - test/unit/test_translation.rb
309
369
  - test/unit/test_validations.rb
310
370
  - LICENSE
311
371
  - UPGRADES
@@ -1,14 +0,0 @@
1
- # To use this, add the following line in environment.rb
2
- # config.middleware.use 'PerRequestIdentityMap'
3
- class PerRequestIdentityMap
4
- def initialize(app)
5
- @app = app
6
- end
7
-
8
- def call(env)
9
- MongoMapper::Plugins::IdentityMap.clear
10
- @app.call(env)
11
- ensure
12
- MongoMapper::Plugins::IdentityMap.clear
13
- end
14
- end
@@ -1,17 +0,0 @@
1
- # encoding: UTF-8
2
- module MongoMapper
3
- module Plugins
4
- module Descendants
5
- module ClassMethods
6
- def inherited(descendant)
7
- descendants << descendant
8
- super
9
- end
10
-
11
- def descendants
12
- @descendants ||= []
13
- end
14
- end
15
- end
16
- end
17
- end
data/rails/init.rb DELETED
@@ -1,19 +0,0 @@
1
- # See http://groups.google.com/group/mongomapper/browse_thread/thread/68f62e8eda43b43a/4841dba76938290c
2
- #
3
- # This is only for development mode. You will still want to clear the identity map before each request in production.
4
- # See examples/identity_map for more on this.
5
- #
6
- # to_prepare is called before each request in development mode and the first request in production.
7
- Rails.configuration.to_prepare do
8
- if Rails.configuration.cache_classes
9
- MongoMapper::Plugins::IdentityMap.clear
10
- else
11
- # Rails reloading was making descendants fill up and leak memory, these make sure they get cleared
12
- MongoMapper::Document.descendants.each {|m| m.descendants.clear if m.respond_to?(:descendants) }
13
- MongoMapper::Document.descendants.clear
14
- MongoMapper::EmbeddedDocument.descendants.each {|m| m.descendants.clear if m.respond_to?(:descendants) }
15
- MongoMapper::EmbeddedDocument.descendants.clear
16
- MongoMapper::Plugins::IdentityMap.clear
17
- MongoMapper::Plugins::IdentityMap.models.clear
18
- end
19
- end