mongoid 4.0.2 → 5.0.0.beta
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +66 -1
- data/README.md +14 -13
- data/lib/config/locales/en.yml +28 -28
- data/lib/mongoid.rb +28 -21
- data/lib/mongoid/atomic.rb +2 -4
- data/lib/mongoid/attributes.rb +7 -7
- data/lib/mongoid/attributes/processing.rb +4 -1
- data/lib/mongoid/attributes/readonly.rb +2 -2
- data/lib/mongoid/changeable.rb +4 -6
- data/lib/mongoid/clients.rb +142 -0
- data/lib/mongoid/clients/factory.rb +78 -0
- data/lib/mongoid/{sessions → clients}/options.rb +30 -19
- data/lib/mongoid/{sessions → clients}/storage_options.rb +27 -13
- data/lib/mongoid/{sessions → clients}/thread_options.rb +6 -3
- data/lib/mongoid/clients/validators.rb +2 -0
- data/lib/mongoid/{sessions → clients}/validators/storage.rb +5 -2
- data/lib/mongoid/composable.rb +3 -3
- data/lib/mongoid/config.rb +39 -41
- data/lib/mongoid/config/environment.rb +1 -1
- data/lib/mongoid/config/validators.rb +1 -1
- data/lib/mongoid/config/validators/{session.rb → client.rb} +31 -28
- data/lib/mongoid/contextual/aggregable/mongo.rb +1 -1
- data/lib/mongoid/contextual/atomic.rb +11 -11
- data/lib/mongoid/contextual/command.rb +9 -6
- data/lib/mongoid/contextual/geo_near.rb +17 -1
- data/lib/mongoid/contextual/map_reduce.rb +12 -11
- data/lib/mongoid/contextual/memory.rb +2 -5
- data/lib/mongoid/contextual/mongo.rb +92 -82
- data/lib/mongoid/contextual/none.rb +13 -0
- data/lib/mongoid/copyable.rb +6 -1
- data/lib/mongoid/criteria.rb +36 -3
- data/lib/mongoid/document.rb +3 -4
- data/lib/mongoid/errors.rb +6 -6
- data/lib/mongoid/errors/{mixed_session_configuration.rb → mixed_client_configuration.rb} +5 -5
- data/lib/mongoid/errors/no_client_config.rb +22 -0
- data/lib/mongoid/errors/{no_session_database.rb → no_client_database.rb} +4 -4
- data/lib/mongoid/errors/{no_session_hosts.rb → no_client_hosts.rb} +4 -4
- data/lib/mongoid/errors/{no_sessions_config.rb → no_clients_config.rb} +4 -4
- data/lib/mongoid/errors/no_default_client.rb +23 -0
- data/lib/mongoid/extensions/hash.rb +5 -1
- data/lib/mongoid/extensions/object.rb +3 -2
- data/lib/mongoid/extensions/set.rb +5 -5
- data/lib/mongoid/factory.rb +4 -2
- data/lib/mongoid/fields.rb +7 -2
- data/lib/mongoid/findable.rb +4 -1
- data/lib/mongoid/indexable.rb +15 -9
- data/lib/mongoid/persistable.rb +1 -2
- data/lib/mongoid/persistable/creatable.rb +2 -2
- data/lib/mongoid/persistable/deletable.rb +3 -3
- data/lib/mongoid/persistable/incrementable.rb +1 -1
- data/lib/mongoid/persistable/logical.rb +1 -1
- data/lib/mongoid/persistable/poppable.rb +1 -1
- data/lib/mongoid/persistable/pullable.rb +2 -2
- data/lib/mongoid/persistable/pushable.rb +2 -2
- data/lib/mongoid/persistable/renamable.rb +1 -1
- data/lib/mongoid/persistable/settable.rb +1 -1
- data/lib/mongoid/persistable/unsettable.rb +1 -1
- data/lib/mongoid/persistable/updatable.rb +2 -2
- data/lib/mongoid/persistable/upsertable.rb +1 -1
- data/lib/mongoid/query_cache.rb +98 -104
- data/lib/mongoid/railtie.rb +1 -21
- data/lib/mongoid/railties/database.rake +1 -1
- data/lib/mongoid/relations/builders.rb +3 -1
- data/lib/mongoid/relations/counter_cache.rb +1 -1
- data/lib/mongoid/relations/embedded/batchable.rb +3 -10
- data/lib/mongoid/relations/embedded/many.rb +4 -2
- data/lib/mongoid/relations/many.rb +1 -0
- data/lib/mongoid/relations/proxy.rb +6 -6
- data/lib/mongoid/relations/referenced/many.rb +2 -1
- data/lib/mongoid/relations/targets/enumerable.rb +11 -11
- data/lib/mongoid/relations/touchable.rb +1 -1
- data/lib/mongoid/reloadable.rb +2 -2
- data/lib/mongoid/scopable.rb +6 -17
- data/lib/mongoid/selectable.rb +1 -36
- data/lib/mongoid/serializable.rb +2 -2
- data/lib/mongoid/stateful.rb +0 -1
- data/lib/mongoid/tasks/database.rake +2 -2
- data/lib/mongoid/tasks/database.rb +23 -16
- data/lib/mongoid/threaded.rb +54 -33
- data/lib/mongoid/threaded/lifecycle.rb +21 -16
- data/lib/mongoid/traversable.rb +16 -1
- data/lib/mongoid/validatable.rb +1 -1
- data/lib/mongoid/validatable/queryable.rb +1 -1
- data/lib/mongoid/validatable/uniqueness.rb +3 -20
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +91 -57
- data/lib/rails/mongoid.rb +2 -2
- data/spec/app/models/audio.rb +1 -1
- data/spec/app/models/band.rb +1 -0
- data/spec/app/models/company.rb +5 -0
- data/spec/app/models/label.rb +7 -0
- data/spec/app/models/pub.rb +6 -0
- data/spec/app/models/staff.rb +7 -0
- data/spec/app/models/store_as_dup_test1.rb +5 -0
- data/spec/app/models/store_as_dup_test2.rb +5 -0
- data/spec/config/mongoid.yml +7 -25
- data/spec/mongoid/atomic/paths_spec.rb +3 -11
- data/spec/mongoid/attributes/nested_spec.rb +16 -16
- data/spec/mongoid/attributes/readonly_spec.rb +80 -18
- data/spec/mongoid/attributes_spec.rb +3 -3
- data/spec/mongoid/changeable_spec.rb +70 -0
- data/spec/mongoid/clients/factory_spec.rb +284 -0
- data/spec/mongoid/{sessions → clients}/options_spec.rb +4 -6
- data/spec/mongoid/clients_spec.rb +739 -0
- data/spec/mongoid/config/environment_spec.rb +14 -11
- data/spec/mongoid/config_spec.rb +33 -48
- data/spec/mongoid/contextual/atomic_spec.rb +1 -17
- data/spec/mongoid/contextual/geo_near_spec.rb +35 -0
- data/spec/mongoid/contextual/mongo_spec.rb +26 -83
- data/spec/mongoid/contextual/none_spec.rb +15 -0
- data/spec/mongoid/copyable_spec.rb +35 -1
- data/spec/mongoid/criteria/findable_spec.rb +197 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +7 -29
- data/spec/mongoid/criteria_spec.rb +74 -91
- data/spec/mongoid/document_spec.rb +1 -1
- data/spec/mongoid/errors/{mixed_session_configuration_spec.rb → mixed_client_configuration_spec.rb} +1 -1
- data/spec/mongoid/errors/{no_session_config_spec.rb → no_client_config_spec.rb} +4 -4
- data/spec/mongoid/errors/{no_session_database_spec.rb → no_client_database_spec.rb} +4 -4
- data/spec/mongoid/errors/{no_session_hosts_spec.rb → no_client_hosts_spec.rb} +3 -3
- data/spec/mongoid/errors/{no_sessions_config_spec.rb → no_clients_config_spec.rb} +2 -2
- data/spec/mongoid/fields/localized_spec.rb +1 -0
- data/spec/mongoid/fields_spec.rb +1 -0
- data/spec/mongoid/findable_spec.rb +2 -23
- data/spec/mongoid/indexable_spec.rb +12 -8
- data/spec/mongoid/interceptable_spec.rb +15 -0
- data/spec/mongoid/persistable/settable_spec.rb +16 -0
- data/spec/mongoid/persistable/updatable_spec.rb +3 -2
- data/spec/mongoid/persistable_spec.rb +4 -4
- data/spec/mongoid/query_cache_spec.rb +13 -8
- data/spec/mongoid/relations/auto_save_spec.rb +1 -1
- data/spec/mongoid/relations/counter_cache_spec.rb +34 -0
- data/spec/mongoid/relations/eager/belongs_to_spec.rb +9 -0
- data/spec/mongoid/relations/eager/has_and_belongs_to_many_spec.rb +3 -3
- data/spec/mongoid/relations/embedded/many_spec.rb +123 -1
- data/spec/mongoid/relations/embedded/one_spec.rb +3 -3
- data/spec/mongoid/relations/proxy_spec.rb +28 -0
- data/spec/mongoid/relations/referenced/in_spec.rb +1 -1
- data/spec/mongoid/relations/referenced/many_spec.rb +47 -23
- data/spec/mongoid/relations/referenced/many_to_many_spec.rb +1 -1
- data/spec/mongoid/relations/referenced/one_spec.rb +1 -1
- data/spec/mongoid/relations/targets/enumerable_spec.rb +9 -2
- data/spec/mongoid/reloadable_spec.rb +6 -6
- data/spec/mongoid/scopable_spec.rb +41 -28
- data/spec/mongoid/selectable_spec.rb +6 -16
- data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
- data/spec/mongoid/tasks/database_spec.rb +2 -2
- data/spec/mongoid/threaded_spec.rb +0 -7
- data/spec/mongoid/traversable_spec.rb +2 -2
- data/spec/mongoid/validatable/uniqueness_spec.rb +30 -1
- data/spec/mongoid_spec.rb +13 -15
- data/spec/rails/mongoid_spec.rb +13 -4
- data/spec/spec_helper.rb +44 -27
- data/spec/support/authorization.rb +12 -0
- data/spec/support/expectations.rb +14 -0
- metadata +52 -59
- data/lib/mongoid/contextual/find_and_modify.rb +0 -69
- data/lib/mongoid/contextual/text_search.rb +0 -178
- data/lib/mongoid/criteria/#findable.rb# +0 -141
- data/lib/mongoid/errors/no_default_session.rb +0 -23
- data/lib/mongoid/errors/no_session_config.rb +0 -22
- data/lib/mongoid/log_subscriber.rb +0 -55
- data/lib/mongoid/positional.rb +0 -71
- data/lib/mongoid/sessions.rb +0 -125
- data/lib/mongoid/sessions/factory.rb +0 -131
- data/lib/mongoid/sessions/mongo_uri.rb +0 -93
- data/lib/mongoid/sessions/validators.rb +0 -2
- data/lib/mongoid/support/query_counter.rb +0 -23
- data/spec/helpers.rb +0 -18
- data/spec/mongoid/#atomic_spec.rb# +0 -365
- data/spec/mongoid/contextual/find_and_modify_spec.rb +0 -220
- data/spec/mongoid/contextual/text_search_spec.rb +0 -209
- data/spec/mongoid/log_subscriber_spec.rb +0 -75
- data/spec/mongoid/positional_spec.rb +0 -222
- data/spec/mongoid/sessions/factory_spec.rb +0 -333
- data/spec/mongoid/sessions/mongo_uri_spec.rb +0 -103
- data/spec/mongoid/sessions_spec.rb +0 -1252
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1ad4f848fcad2ee5ad4eee51d2d31eb444d900
|
4
|
+
data.tar.gz: a373cbfa6a5541b9bbc3dd37b119458c91bb16fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ff95e684aca5bc7a4b1d3293a3f1dd6feb5ad24e1d711f86db32a6d7b5cd86159846ee23524376ecfccf8638d837928a10f8514ed015e65d38be5b8bf466f9a
|
7
|
+
data.tar.gz: fba913e1cdb0a81796016bb266d8fbd14173f044e53ad94de35576f017b2373009302d57f9ab736458e7fdda5587391a505e1ba6de47a880ac0a6d3f2942e01a
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,72 @@
|
|
3
3
|
For instructions on upgrading to newer versions, visit
|
4
4
|
[mongoid.org](http://mongoid.org/en/mongoid/docs/upgrading.html).
|
5
5
|
|
6
|
-
##
|
6
|
+
## 5.0.0 - Not released
|
7
|
+
|
8
|
+
### Major Changes (Backwards Incompatible)
|
9
|
+
|
10
|
+
* Mongoid now uses the official Mongo Ruby Driver 2.x instead of Moped.
|
11
|
+
|
12
|
+
* Most driver specific configuration options have changed, please see [here](http://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial/#ruby-options) for the new options.
|
13
|
+
|
14
|
+
* All references to `session` are now replaced with `client`. This includes the mongoid.yml configuration, `store_in` options, and all exceptions and modules with `Session` in the name.
|
15
|
+
|
16
|
+
* `find_and_modify` has been removed and replaced with 3 options: `find_one_and_update`, `find_one_and_delete` and `find_one_and_replace`.
|
17
|
+
|
18
|
+
* `text_search` has been removed as it is now a `$text` option in a query from 2.6 on.
|
19
|
+
|
20
|
+
* Mongoid no longer supports MongoDB 2.2 - support is now for only 2.4 and higher.
|
21
|
+
|
22
|
+
* \#3768 `first` and `last` no longer add an `_id` sort when no sorting options have been provided. In order to guarantee that a document is the first or last, it needs to now contain an explicit sort.
|
23
|
+
|
24
|
+
* `Document#deleted?` alias has been removed, please continue to use `Document#destroyed?`.
|
25
|
+
|
26
|
+
### New Features
|
27
|
+
|
28
|
+
* \#4016 Allow private and protected setters on fields for atomic operations. (Rob Smith)
|
29
|
+
|
30
|
+
* \#3985 Return nil when using `{upsert: true}` in `find_and_modify` (Adrien Siami)
|
31
|
+
|
32
|
+
* \#3963 Allow extended JSON object ids to be passed to `find`.
|
33
|
+
|
34
|
+
* \#3846 Allow #pluck when none is used in criteria. (Braulio Martinez)
|
35
|
+
|
36
|
+
### Resolved Issues
|
37
|
+
|
38
|
+
* \#4091 Use sublcass context when calling a scope defined in a superclass. (Edgars Beigarts)
|
39
|
+
|
40
|
+
* \#4075 Made remove index logging specific to each index that was actually getting removed.
|
41
|
+
|
42
|
+
* \#4071 Fixed loading of enumerable relation to check the added documents when iterating.
|
43
|
+
|
44
|
+
* \#4077 Many relations now include Enumerable.
|
45
|
+
|
46
|
+
* \#4052 Fixed uniqueness validation on localized fields with no value.
|
47
|
+
|
48
|
+
* \#4033 Removed all uses of the $ positional operator in atomic updates.
|
49
|
+
|
50
|
+
* \#4030 Dup/clone exceptions auto-include dynamic attributes.
|
51
|
+
|
52
|
+
* \#4005 Fixed inclusion of mongoid with Rails components that don't have the Rails environment.
|
53
|
+
|
54
|
+
* \#3993 Fixes issue where `dup`/`clone` fails for embedded documents that use store_as without using Mongoid::Atributes::Dynamic
|
55
|
+
|
56
|
+
* \#3991 Fixed emebdded documents not flagging as changed after calling #changed? and modifying the
|
57
|
+
child elements.
|
58
|
+
|
59
|
+
* \#3874 Adding snapshot option to context.
|
60
|
+
|
61
|
+
* \#3868 Loading models in rake tasks now expands the rails path.
|
62
|
+
|
63
|
+
* \#3764 Fixed case statement check for enumerable targets.
|
64
|
+
|
65
|
+
* \#3740 Fixes `Missing attribute: '_id'` error when using methods only or without (dx7)
|
66
|
+
|
67
|
+
* \#3631 Fixes issue where `before_save` callback can get called twice after a child create
|
68
|
+
|
69
|
+
* \#3599 Fixed application of default scopes from superclass in subclasses.
|
70
|
+
|
71
|
+
* \#3104 Fixed enumerable targets to check first/last in proper order.
|
7
72
|
|
8
73
|
## 4.0.2
|
9
74
|
|
data/README.md
CHANGED
@@ -7,6 +7,18 @@
|
|
7
7
|
|
8
8
|
Mongoid is an ODM (Object-Document-Mapper) framework for MongoDB in Ruby.
|
9
9
|
|
10
|
+
Project Move and Support
|
11
|
+
------------------------
|
12
|
+
|
13
|
+
For the upcoming 5.0.0 release, the repository will be getting moved to the MongoDB
|
14
|
+
organization. Please pay special attention to the following information with regards
|
15
|
+
to this move:
|
16
|
+
|
17
|
+
* 5.0.0 and higher releases of Mongoid will be officially supported by MongoDB with a dedicated team.
|
18
|
+
* Issues tagged 5.0.0 and higher in Github will be migrated to the [Mongoid Jira project](https://jira.mongodb.org/browse/MONGOID/) upon the release. There will be no more Github issues.
|
19
|
+
* 4.x and 3.x releases will no longer be supported. Fixes to these branches will need to be maintained in community forks, although not recommended.
|
20
|
+
* 5.0.0 release will still be supporting Rails 4.x, although there will be some backwards incompatible changes with respect to the configuration options. The Mongoid public API itself will not be changed.
|
21
|
+
|
10
22
|
Project Tracking
|
11
23
|
----------------
|
12
24
|
|
@@ -18,7 +30,7 @@ Project Tracking
|
|
18
30
|
Compatibility
|
19
31
|
-------------
|
20
32
|
|
21
|
-
Mongoid is tested against MRI 1.9.3, 2.0.0, 2.1.0 and JRuby (1.9).
|
33
|
+
Mongoid is tested against MRI 1.9.3, 2.0.0, 2.1.0. 2.2.0 and JRuby (1.9).
|
22
34
|
|
23
35
|
Documentation
|
24
36
|
-------------
|
@@ -26,21 +38,10 @@ Documentation
|
|
26
38
|
Please see the new Mongoid website for up-to-date documentation:
|
27
39
|
[mongoid.org](http://mongoid.org)
|
28
40
|
|
29
|
-
Donating
|
30
|
-
--------
|
31
|
-
|
32
|
-
[Support Mongoid at Pledgie](http://www.pledgie.com/campaigns/7757)
|
33
|
-
|
34
|
-
<a href='http://www.pledgie.com/campaigns/7757'>
|
35
|
-
<img alt='Click here to lend your support to: Mongoid and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/7757.png?skin_name=chrome' border='0'/>
|
36
|
-
</a>
|
37
|
-
|
38
|
-
[](https://flattr.com/submit/auto?user_id=durran&url=http://github.com/mongoid&title=mongoid&language=&tags=github&category=software)
|
39
|
-
|
40
41
|
License
|
41
42
|
-------
|
42
43
|
|
43
|
-
Copyright (c) 2009-
|
44
|
+
Copyright (c) 2009-2015 Durran Jordan
|
44
45
|
|
45
46
|
Permission is hereby granted, free of charge, to any person obtaining
|
46
47
|
a copy of this software and associated documentation files (the
|
data/lib/config/locales/en.yml
CHANGED
@@ -175,7 +175,7 @@ en:
|
|
175
175
|
invalid_storage_options:
|
176
176
|
message: "Invalid options passed to %{klass}.store_in: %{options}."
|
177
177
|
summary: "The :store_in macro takes only a hash of parameters with
|
178
|
-
the keys :database, :collection, or :
|
178
|
+
the keys :database, :collection, or :client."
|
179
179
|
resolution: "Change the options passed to store_in to match the
|
180
180
|
documented API, and ensure all keys in the options hash are
|
181
181
|
symbols.\n\n
|
@@ -249,9 +249,9 @@ en:
|
|
249
249
|
for each parent up the hierarchy."
|
250
250
|
resolution: "Consider not embedding %{embedded}, or do the key
|
251
251
|
storage and access in a custom manner in the application code."
|
252
|
-
|
252
|
+
mixed_client_configuration:
|
253
253
|
message: "Both uri and standard configuration options defined for
|
254
|
-
|
254
|
+
client: '%{name}'."
|
255
255
|
summary: "Instead of simply giving uri or standard options a
|
256
256
|
preference order, Mongoid assumes that you have made a mistake in
|
257
257
|
your configuration and requires that you provide one or the other,
|
@@ -276,15 +276,15 @@ en:
|
|
276
276
|
\_\_\_\_has_many :albums\n
|
277
277
|
\_\_\_\_accepts_nested_attributes_for :albums\n
|
278
278
|
\_\_end\n\n"
|
279
|
-
|
280
|
-
message: "No default
|
279
|
+
no_default_client:
|
280
|
+
message: "No default client configuration is defined."
|
281
281
|
summary: "The configuration provided settings for: %{keys}, but
|
282
282
|
Mongoid requires a :default to be defined at minimum."
|
283
283
|
resolution: "If configuring via a mongoid.yml, ensure that within
|
284
|
-
your :
|
284
|
+
your :clients section a :default client is defined.\n\n
|
285
285
|
Example:\n
|
286
286
|
\_\_development:\n
|
287
|
-
\_\_\_\
|
287
|
+
\_\_\_\_clients:\n
|
288
288
|
\_\_\_\_\_\_default:\n
|
289
289
|
\_\_\_\_\_\_\_\_hosts:\n
|
290
290
|
\_\_\_\_\_\_\_\_\_\_- localhost:27017\n\n"
|
@@ -338,59 +338,59 @@ en:
|
|
338
338
|
resolution: "Ensure that you've set the parent relation if
|
339
339
|
instantiating the embedded document directly, or always create new
|
340
340
|
embedded documents via the parent relation."
|
341
|
-
|
342
|
-
message: "No configuration could be found for a
|
341
|
+
no_client_config:
|
342
|
+
message: "No configuration could be found for a client named
|
343
343
|
'%{name}'."
|
344
|
-
summary: "When attempting to create the new
|
345
|
-
not find a
|
344
|
+
summary: "When attempting to create the new client, Mongoid could
|
345
|
+
not find a client configuration for the name: '%{name}'. This is
|
346
346
|
necessary in order to know the host, port, and options needed
|
347
347
|
to connect."
|
348
348
|
resolution: "Double check your mongoid.yml to make sure under the
|
349
|
-
|
349
|
+
clients key that a configuration exists for '%{name}'. If you
|
350
350
|
have set the configuration programatically, ensure that '%{name}'
|
351
351
|
exists in the configuration hash."
|
352
|
-
|
353
|
-
message: "No
|
352
|
+
no_clients_config:
|
353
|
+
message: "No clients configuration provided."
|
354
354
|
summary: "Mongoid's configuration requires that you provide details
|
355
|
-
about each
|
356
|
-
the
|
355
|
+
about each client that can be connected to, and requires in
|
356
|
+
the clients config at least 1 default client to exist."
|
357
357
|
resolution: "Double check your mongoid.yml to make sure that you
|
358
|
-
have a top-level
|
358
|
+
have a top-level clients key with at least 1 default client
|
359
359
|
configuration for it. You can regenerate a new mongoid.yml for
|
360
360
|
assistance via `rails g mongoid:config`.\n\n
|
361
361
|
Example:\n
|
362
362
|
\_\_development:\n
|
363
|
-
\_\_\_\
|
363
|
+
\_\_\_\_clients:\n
|
364
364
|
\_\_\_\_\_\_default:\n
|
365
365
|
\_\_\_\_\_\_\_\_database: mongoid_dev\n
|
366
366
|
\_\_\_\_\_\_\_\_hosts:\n
|
367
367
|
\_\_\_\_\_\_\_\_\_\_- localhost:27017\n\n"
|
368
|
-
|
369
|
-
message: "No database provided for
|
370
|
-
summary: "Each
|
368
|
+
no_client_database:
|
369
|
+
message: "No database provided for client configuration: :%{name}."
|
370
|
+
summary: "Each client configuration must provide a database so Mongoid
|
371
371
|
knows where the default database to persist to. What was provided
|
372
372
|
was: %{config}."
|
373
373
|
resolution: "If configuring via a mongoid.yml, ensure that within
|
374
|
-
your :%{name} section a :database value for the
|
374
|
+
your :%{name} section a :database value for the client's default
|
375
375
|
database is defined.\n\n
|
376
376
|
Example:\n
|
377
377
|
\_\_development:\n
|
378
|
-
\_\_\_\
|
378
|
+
\_\_\_\_clients:\n
|
379
379
|
\_\_\_\_\_\_%{name}:\n
|
380
380
|
\_\_\_\_\_\_\_\_database: my_app_db\n
|
381
381
|
\_\_\_\_\_\_\_\_hosts:\n
|
382
382
|
\_\_\_\_\_\_\_\_\_\_- localhost:27017\n\n"
|
383
|
-
|
384
|
-
message: "No hosts provided for
|
385
|
-
summary: "Each
|
383
|
+
no_client_hosts:
|
384
|
+
message: "No hosts provided for client configuration: :%{name}."
|
385
|
+
summary: "Each client configuration must provide hosts so Mongoid
|
386
386
|
knows where the database server is located. What was provided
|
387
387
|
was: %{config}."
|
388
388
|
resolution: "If configuring via a mongoid.yml, ensure that within
|
389
|
-
your :%{name} section a :hosts value for the
|
389
|
+
your :%{name} section a :hosts value for the client hosts is
|
390
390
|
defined.\n\n
|
391
391
|
Example:\n
|
392
392
|
\_\_development:\n
|
393
|
-
\_\_\_\
|
393
|
+
\_\_\_\_clients:\n
|
394
394
|
\_\_\_\_\_\_%{name}:\n
|
395
395
|
\_\_\_\_\_\_\_\_database: my_app_db\n
|
396
396
|
\_\_\_\_\_\_\_\_hosts:\n
|
data/lib/mongoid.rb
CHANGED
@@ -13,14 +13,13 @@ require "active_support/time_with_zone"
|
|
13
13
|
require "active_model"
|
14
14
|
|
15
15
|
require "origin"
|
16
|
-
require "
|
16
|
+
require "mongo"
|
17
17
|
|
18
18
|
require "mongoid/version"
|
19
19
|
require "mongoid/config"
|
20
20
|
require "mongoid/loggable"
|
21
|
-
require "mongoid/
|
21
|
+
require "mongoid/clients"
|
22
22
|
require "mongoid/document"
|
23
|
-
require "mongoid/log_subscriber"
|
24
23
|
require "mongoid/tasks/database"
|
25
24
|
require "mongoid/query_cache"
|
26
25
|
|
@@ -35,9 +34,11 @@ I18n.load_path << File.join(File.dirname(__FILE__), "config", "locales", "en.yml
|
|
35
34
|
|
36
35
|
module Mongoid
|
37
36
|
extend Loggable
|
37
|
+
extend Gem::Deprecate
|
38
38
|
extend self
|
39
39
|
|
40
|
-
|
40
|
+
# The minimum MongoDB version supported.
|
41
|
+
MONGODB_VERSION = "2.4.0"
|
41
42
|
|
42
43
|
# Sets the Mongoid configuration options. Best used by passing a block.
|
43
44
|
#
|
@@ -53,41 +54,47 @@ module Mongoid
|
|
53
54
|
block_given? ? yield(Config) : Config
|
54
55
|
end
|
55
56
|
|
56
|
-
# Convenience method for getting the default
|
57
|
+
# Convenience method for getting the default client.
|
57
58
|
#
|
58
|
-
# @example Get the default
|
59
|
-
# Mongoid.
|
59
|
+
# @example Get the default client.
|
60
|
+
# Mongoid.default_client
|
60
61
|
#
|
61
|
-
# @return [
|
62
|
+
# @return [ Mongo::Client ] The default client.
|
62
63
|
#
|
63
64
|
# @since 3.0.0
|
64
|
-
def
|
65
|
-
|
65
|
+
def default_client
|
66
|
+
Clients.default
|
66
67
|
end
|
68
|
+
alias :default_session :default_client
|
69
|
+
deprecate :default_session, :default_client, 2015, 12
|
67
70
|
|
68
|
-
# Disconnect all active
|
71
|
+
# Disconnect all active clients.
|
69
72
|
#
|
70
|
-
# @example Disconnect all active
|
71
|
-
# Mongoid.
|
73
|
+
# @example Disconnect all active clients.
|
74
|
+
# Mongoid.disconnect_clients
|
72
75
|
#
|
73
76
|
# @return [ true ] True.
|
74
77
|
#
|
75
78
|
# @since 3.1.0
|
76
|
-
def
|
77
|
-
|
79
|
+
def disconnect_clients
|
80
|
+
Clients.disconnect
|
78
81
|
end
|
82
|
+
alias :disconnect_sessions :disconnect_clients
|
83
|
+
deprecate :disconnect_sessions, :disconnect_clients, 2015, 12
|
79
84
|
|
80
|
-
# Convenience method for getting a named
|
85
|
+
# Convenience method for getting a named client.
|
81
86
|
#
|
82
|
-
# @example Get a named
|
83
|
-
# Mongoid.
|
87
|
+
# @example Get a named client.
|
88
|
+
# Mongoid.client(:default)
|
84
89
|
#
|
85
|
-
# @return [
|
90
|
+
# @return [ Mongo::Client ] The named client.
|
86
91
|
#
|
87
92
|
# @since 3.0.0
|
88
|
-
def
|
89
|
-
|
93
|
+
def client(name)
|
94
|
+
Clients.with_name(name)
|
90
95
|
end
|
96
|
+
alias :session :client
|
97
|
+
deprecate :session, :client, 2015, 12
|
91
98
|
|
92
99
|
# Take all the public instance methods from the Config singleton and allow
|
93
100
|
# them to be accessed through the Mongoid module directly.
|
data/lib/mongoid/atomic.rb
CHANGED
@@ -329,9 +329,7 @@ module Mongoid
|
|
329
329
|
# @since 3.0.10
|
330
330
|
def process_flagged_destroys
|
331
331
|
_assigning do
|
332
|
-
flagged_destroys.each
|
333
|
-
block.call
|
334
|
-
end
|
332
|
+
flagged_destroys.each(&:call)
|
335
333
|
end
|
336
334
|
flagged_destroys.clear
|
337
335
|
end
|
@@ -373,7 +371,7 @@ module Mongoid
|
|
373
371
|
# @since 3.0.6
|
374
372
|
def touch_atomic_updates(field = nil)
|
375
373
|
updates = atomic_updates
|
376
|
-
return {} unless atomic_updates.
|
374
|
+
return {} unless atomic_updates.key?("$set")
|
377
375
|
touches = {}
|
378
376
|
updates["$set"].each_pair do |key, value|
|
379
377
|
touches.merge!({ key => value }) if key =~ /updated_at|#{field}/
|
data/lib/mongoid/attributes.rb
CHANGED
@@ -58,7 +58,7 @@ module Mongoid
|
|
58
58
|
#
|
59
59
|
# @since 3.0.0
|
60
60
|
def has_attribute?(name)
|
61
|
-
attributes.
|
61
|
+
attributes.key?(name.to_s)
|
62
62
|
end
|
63
63
|
|
64
64
|
# Does the document have the provided attribute before it was assigned
|
@@ -74,7 +74,7 @@ module Mongoid
|
|
74
74
|
#
|
75
75
|
# @since 3.1.0
|
76
76
|
def has_attribute_before_type_cast?(name)
|
77
|
-
attributes_before_type_cast.
|
77
|
+
attributes_before_type_cast.key?(name.to_s)
|
78
78
|
end
|
79
79
|
|
80
80
|
# Read a value from the document attributes. If the value does not exist
|
@@ -119,7 +119,7 @@ module Mongoid
|
|
119
119
|
# @since 3.1.0
|
120
120
|
def read_attribute_before_type_cast(name)
|
121
121
|
attr = name.to_s
|
122
|
-
if attributes_before_type_cast.
|
122
|
+
if attributes_before_type_cast.key?(attr)
|
123
123
|
attributes_before_type_cast[attr]
|
124
124
|
else
|
125
125
|
read_attribute(attr)
|
@@ -256,9 +256,9 @@ module Mongoid
|
|
256
256
|
|
257
257
|
def selection_included?(name, selection, field)
|
258
258
|
if field && field.localized?
|
259
|
-
selection.
|
259
|
+
selection.key?("#{name}.#{::I18n.locale}")
|
260
260
|
else
|
261
|
-
selection.
|
261
|
+
selection.key?(name)
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
@@ -273,7 +273,7 @@ module Mongoid
|
|
273
273
|
#
|
274
274
|
# @since 3.0.15
|
275
275
|
def hash_dot_syntax?(string)
|
276
|
-
string.include?(".")
|
276
|
+
string.include?(".".freeze)
|
277
277
|
end
|
278
278
|
|
279
279
|
# Return the typecasted value for a field.
|
@@ -288,7 +288,7 @@ module Mongoid
|
|
288
288
|
#
|
289
289
|
# @since 1.0.0
|
290
290
|
def typed_value_for(key, value)
|
291
|
-
fields.
|
291
|
+
fields.key?(key) ? fields[key].mongoize(value) : value.mongoize
|
292
292
|
end
|
293
293
|
|
294
294
|
module ClassMethods
|
@@ -92,7 +92,10 @@ module Mongoid
|
|
92
92
|
#
|
93
93
|
# @since 2.0.0.rc.7
|
94
94
|
def process_attribute(name, value)
|
95
|
-
|
95
|
+
if !respond_to?("#{name}=", true) && store_as = aliased_fields.invert[name.to_s]
|
96
|
+
name = store_as
|
97
|
+
end
|
98
|
+
responds = respond_to?("#{name}=", true)
|
96
99
|
raise Errors::UnknownAttribute.new(self.class, name) unless responds
|
97
100
|
send("#{name}=", value)
|
98
101
|
end
|
@@ -23,7 +23,7 @@ module Mongoid
|
|
23
23
|
#
|
24
24
|
# @since 3.0.0
|
25
25
|
def attribute_writable?(name)
|
26
|
-
new_record? || !readonly_attributes.include?(name
|
26
|
+
new_record? || !readonly_attributes.include?(database_field_name(name))
|
27
27
|
end
|
28
28
|
|
29
29
|
module ClassMethods
|
@@ -47,7 +47,7 @@ module Mongoid
|
|
47
47
|
# @since 3.0.0
|
48
48
|
def attr_readonly(*names)
|
49
49
|
names.each do |name|
|
50
|
-
readonly_attributes << name
|
50
|
+
readonly_attributes << database_field_name(name)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|