mongoid 7.1.0.rc0 → 7.2.0.rc1
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +6 -6
- data/LICENSE +1 -1
- data/README.md +14 -7
- data/Rakefile +21 -0
- data/lib/config/locales/en.yml +42 -6
- data/lib/mongoid.rb +26 -2
- data/lib/mongoid/association/accessors.rb +37 -2
- data/lib/mongoid/association/depending.rb +1 -6
- data/lib/mongoid/association/embedded/embeds_many.rb +2 -1
- data/lib/mongoid/association/embedded/embeds_one.rb +2 -1
- data/lib/mongoid/association/many.rb +5 -4
- data/lib/mongoid/association/proxy.rb +6 -4
- data/lib/mongoid/association/referenced/belongs_to/binding.rb +1 -1
- data/lib/mongoid/association/referenced/belongs_to/buildable.rb +1 -1
- data/lib/mongoid/association/referenced/belongs_to/eager.rb +38 -2
- data/lib/mongoid/association/referenced/eager.rb +29 -9
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +30 -15
- data/lib/mongoid/association/referenced/has_many/proxy.rb +11 -3
- data/lib/mongoid/association/referenced/has_one/buildable.rb +1 -1
- data/lib/mongoid/atomic.rb +13 -3
- data/lib/mongoid/atomic/modifiers.rb +1 -1
- data/lib/mongoid/attributes.rb +28 -20
- data/lib/mongoid/attributes/dynamic.rb +1 -1
- data/lib/mongoid/clients/factory.rb +19 -2
- data/lib/mongoid/clients/options.rb +8 -8
- data/lib/mongoid/clients/sessions.rb +20 -4
- data/lib/mongoid/clients/storage_options.rb +5 -5
- data/lib/mongoid/composable.rb +1 -0
- data/lib/mongoid/config.rb +45 -12
- data/lib/mongoid/config/options.rb +5 -2
- data/lib/mongoid/contextual.rb +5 -4
- data/lib/mongoid/contextual/geo_near.rb +3 -2
- data/lib/mongoid/contextual/map_reduce.rb +3 -2
- data/lib/mongoid/contextual/mongo.rb +25 -5
- data/lib/mongoid/copyable.rb +2 -2
- data/lib/mongoid/criteria.rb +80 -11
- data/lib/mongoid/criteria/modifiable.rb +2 -1
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/regexp.rb +6 -6
- data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +12 -0
- data/lib/mongoid/criteria/queryable/key.rb +1 -1
- data/lib/mongoid/criteria/queryable/mergeable.rb +75 -8
- data/lib/mongoid/criteria/queryable/pipeline.rb +3 -2
- data/lib/mongoid/criteria/queryable/selectable.rb +141 -19
- data/lib/mongoid/criteria/queryable/selector.rb +3 -3
- data/lib/mongoid/criteria/queryable/storable.rb +106 -101
- data/lib/mongoid/document.rb +15 -3
- data/lib/mongoid/errors.rb +7 -0
- data/lib/mongoid/errors/eager_load.rb +2 -0
- data/lib/mongoid/errors/invalid_discriminator_key_target.rb +25 -0
- data/lib/mongoid/errors/invalid_elem_match_operator.rb +33 -0
- data/lib/mongoid/errors/invalid_estimated_count_criteria.rb +26 -0
- data/lib/mongoid/errors/invalid_expression_operator.rb +28 -0
- data/lib/mongoid/errors/invalid_field_operator.rb +33 -0
- data/lib/mongoid/errors/invalid_query.rb +41 -0
- data/lib/mongoid/errors/no_client_config.rb +2 -2
- data/lib/mongoid/errors/no_default_client.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +4 -2
- data/lib/mongoid/extensions/regexp.rb +1 -1
- data/lib/mongoid/factory.rb +27 -10
- data/lib/mongoid/fields.rb +2 -1
- data/lib/mongoid/fields/standard.rb +2 -1
- data/lib/mongoid/fields/validators/macro.rb +26 -10
- data/lib/mongoid/findable.rb +55 -18
- data/lib/mongoid/indexable.rb +2 -2
- data/lib/mongoid/interceptable.rb +5 -1
- data/lib/mongoid/matchable.rb +1 -149
- data/lib/mongoid/matcher.rb +127 -0
- data/lib/mongoid/matcher/all.rb +22 -0
- data/lib/mongoid/matcher/and.rb +21 -0
- data/lib/mongoid/matcher/elem_match.rb +35 -0
- data/lib/mongoid/matcher/elem_match_expression.rb +20 -0
- data/lib/mongoid/matcher/eq.rb +11 -0
- data/lib/mongoid/matcher/eq_impl.rb +32 -0
- data/lib/mongoid/matcher/eq_impl_with_regexp.rb +21 -0
- data/lib/mongoid/matcher/exists.rb +15 -0
- data/lib/mongoid/matcher/expression.rb +40 -0
- data/lib/mongoid/matcher/expression_operator.rb +19 -0
- data/lib/mongoid/matcher/field_expression.rb +63 -0
- data/lib/mongoid/matcher/field_operator.rb +52 -0
- data/lib/mongoid/matcher/gt.rb +17 -0
- data/lib/mongoid/matcher/gte.rb +17 -0
- data/lib/mongoid/matcher/in.rb +25 -0
- data/lib/mongoid/matcher/lt.rb +17 -0
- data/lib/mongoid/matcher/lte.rb +17 -0
- data/lib/mongoid/matcher/ne.rb +16 -0
- data/lib/mongoid/matcher/nin.rb +11 -0
- data/lib/mongoid/matcher/nor.rb +25 -0
- data/lib/mongoid/matcher/not.rb +29 -0
- data/lib/mongoid/matcher/or.rb +21 -0
- data/lib/mongoid/matcher/regex.rb +41 -0
- data/lib/mongoid/matcher/size.rb +26 -0
- data/lib/mongoid/persistable/deletable.rb +1 -1
- data/lib/mongoid/persistable/pushable.rb +11 -2
- data/lib/mongoid/persistence_context.rb +6 -6
- data/lib/mongoid/query_cache.rb +83 -38
- data/lib/mongoid/railties/database.rake +7 -0
- data/lib/mongoid/reloadable.rb +2 -2
- data/lib/mongoid/serializable.rb +11 -3
- data/lib/mongoid/shardable.rb +56 -4
- data/lib/mongoid/tasks/database.rake +10 -5
- data/lib/mongoid/tasks/database.rb +83 -0
- data/lib/mongoid/timestamps/timeless.rb +3 -1
- data/lib/mongoid/traversable.rb +111 -4
- data/lib/mongoid/validatable/uniqueness.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +32 -23
- data/lib/rails/generators/mongoid/model/templates/model.rb.tt +1 -1
- data/spec/integration/app_spec.rb +254 -0
- data/spec/integration/associations/embedded_spec.rb +148 -0
- data/spec/integration/associations/has_many_spec.rb +69 -0
- data/spec/integration/associations/has_one_spec.rb +69 -0
- data/spec/integration/associations/nested_attributes_assignment_spec.rb +116 -0
- data/spec/integration/atomic/modifiers_spec.rb +117 -0
- data/spec/integration/bson_regexp_raw_spec.rb +20 -0
- data/spec/integration/criteria/date_field_spec.rb +41 -0
- data/spec/integration/criteria/logical_spec.rb +13 -0
- data/spec/integration/discriminator_key_spec.rb +354 -0
- data/spec/integration/discriminator_value_spec.rb +207 -0
- data/spec/integration/document_spec.rb +22 -0
- data/spec/integration/{matchable_spec.rb → matcher_examples_spec.rb} +120 -41
- data/spec/integration/matcher_operator_data/all.yml +140 -0
- data/spec/integration/matcher_operator_data/and.yml +93 -0
- data/spec/integration/matcher_operator_data/elem_match.yml +363 -0
- data/spec/integration/matcher_operator_data/elem_match_expr.yml +213 -0
- data/spec/integration/matcher_operator_data/eq.yml +191 -0
- data/spec/integration/matcher_operator_data/exists.yml +213 -0
- data/spec/integration/matcher_operator_data/generic_op.yml +17 -0
- data/spec/integration/matcher_operator_data/gt.yml +132 -0
- data/spec/integration/matcher_operator_data/gte.yml +132 -0
- data/spec/integration/matcher_operator_data/implicit.yml +331 -0
- data/spec/integration/matcher_operator_data/implicit_traversal.yml +16 -0
- data/spec/integration/matcher_operator_data/in.yml +194 -0
- data/spec/integration/matcher_operator_data/invalid_op.yml +59 -0
- data/spec/integration/matcher_operator_data/invalid_syntax.yml +39 -0
- data/spec/integration/matcher_operator_data/lt.yml +132 -0
- data/spec/integration/matcher_operator_data/lte.yml +132 -0
- data/spec/integration/matcher_operator_data/multiple.yml +29 -0
- data/spec/integration/matcher_operator_data/ne.yml +150 -0
- data/spec/integration/matcher_operator_data/nin.yml +114 -0
- data/spec/integration/matcher_operator_data/nor.yml +126 -0
- data/spec/integration/matcher_operator_data/not.yml +196 -0
- data/spec/integration/matcher_operator_data/or.yml +137 -0
- data/spec/integration/matcher_operator_data/regex.yml +174 -0
- data/spec/integration/matcher_operator_data/regex_options.yml +72 -0
- data/spec/integration/matcher_operator_data/size.yml +174 -0
- data/spec/integration/matcher_operator_spec.rb +100 -0
- data/spec/integration/matcher_spec.rb +189 -0
- data/spec/integration/server_query_spec.rb +142 -0
- data/spec/integration/shardable_spec.rb +149 -0
- data/spec/lite_spec_helper.rb +15 -4
- data/spec/mongoid/association/accessors_spec.rb +238 -63
- data/spec/mongoid/association/depending_spec.rb +78 -26
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +33 -0
- data/spec/mongoid/association/embedded/embeds_many_models.rb +20 -0
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +10 -0
- data/spec/mongoid/association/embedded/embeds_one_models.rb +1 -0
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +0 -2
- data/spec/mongoid/association/referenced/belongs_to/eager_spec.rb +193 -10
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +140 -1
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +146 -68
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +462 -187
- data/spec/mongoid/association/referenced/has_many_models.rb +9 -0
- data/spec/mongoid/association/referenced/has_one_models.rb +9 -0
- data/spec/mongoid/atomic/modifiers_spec.rb +47 -0
- data/spec/mongoid/atomic_spec.rb +23 -0
- data/spec/mongoid/attributes/nested_spec.rb +1 -1
- data/spec/mongoid/attributes_spec.rb +19 -7
- data/spec/mongoid/changeable_spec.rb +23 -0
- data/spec/mongoid/clients/factory_spec.rb +45 -8
- data/spec/mongoid/clients/options_spec.rb +11 -11
- data/spec/mongoid/clients/sessions_spec.rb +9 -10
- data/spec/mongoid/clients/transactions_spec.rb +20 -8
- data/spec/mongoid/clients_spec.rb +2 -2
- data/spec/mongoid/config_spec.rb +28 -0
- data/spec/mongoid/contextual/atomic_spec.rb +22 -11
- data/spec/mongoid/contextual/geo_near_spec.rb +11 -2
- data/spec/mongoid/contextual/map_reduce_spec.rb +20 -5
- data/spec/mongoid/contextual/mongo_spec.rb +146 -69
- data/spec/mongoid/copyable_spec.rb +153 -1
- data/spec/mongoid/copyable_spec_models.rb +14 -0
- data/spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +7 -7
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +19 -7
- data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +28 -1
- data/spec/mongoid/criteria/queryable/mergeable_spec.rb +45 -12
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +1051 -392
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +136 -82
- data/spec/mongoid/criteria/queryable/storable_spec.rb +80 -2
- data/spec/mongoid/criteria_spec.rb +240 -41
- data/spec/mongoid/document_fields_spec.rb +29 -0
- data/spec/mongoid/document_persistence_context_spec.rb +33 -0
- data/spec/mongoid/document_spec.rb +89 -15
- data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
- data/spec/mongoid/errors/no_client_config_spec.rb +2 -2
- data/spec/mongoid/errors/no_client_database_spec.rb +3 -3
- data/spec/mongoid/errors/no_client_hosts_spec.rb +3 -3
- data/spec/mongoid/factory_spec.rb +261 -28
- data/spec/mongoid/fields_spec.rb +72 -3
- data/spec/mongoid/findable_spec.rb +32 -0
- data/spec/mongoid/indexable_spec.rb +34 -6
- data/spec/mongoid/inspectable_spec.rb +29 -2
- data/spec/mongoid/interceptable_spec.rb +64 -2
- data/spec/mongoid/interceptable_spec_models.rb +76 -0
- data/spec/mongoid/matcher/extract_attribute_data/traversal.yml +259 -0
- data/spec/mongoid/matcher/extract_attribute_spec.rb +47 -0
- data/spec/mongoid/persistable/creatable_spec.rb +108 -25
- data/spec/mongoid/persistable/deletable_spec.rb +86 -0
- data/spec/mongoid/persistable/pushable_spec.rb +55 -1
- data/spec/mongoid/persistable/savable_spec.rb +174 -16
- data/spec/mongoid/query_cache_middleware_spec.rb +16 -3
- data/spec/mongoid/query_cache_spec.rb +498 -29
- data/spec/mongoid/relations/proxy_spec.rb +1 -1
- data/spec/mongoid/reloadable_spec.rb +72 -0
- data/spec/mongoid/scopable_spec.rb +2 -1
- data/spec/mongoid/serializable_spec.rb +149 -20
- data/spec/mongoid/shardable_models.rb +61 -0
- data/spec/mongoid/shardable_spec.rb +69 -16
- data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
- data/spec/mongoid/tasks/database_spec.rb +1 -1
- data/spec/mongoid/traversable_spec.rb +1100 -0
- data/spec/spec_helper.rb +4 -33
- data/spec/support/child_process_helper.rb +79 -0
- data/spec/support/cluster_config.rb +3 -3
- data/spec/support/constraints.rb +50 -10
- data/spec/support/expectations.rb +3 -1
- data/spec/support/helpers.rb +11 -0
- data/spec/support/lite_constraints.rb +22 -0
- data/spec/{app → support}/models/account.rb +0 -0
- data/spec/{app → support}/models/acolyte.rb +0 -0
- data/spec/{app → support}/models/actor.rb +1 -1
- data/spec/{app → support}/models/actress.rb +0 -0
- data/spec/{app → support}/models/address.rb +0 -0
- data/spec/{app → support}/models/address_component.rb +0 -0
- data/spec/{app → support}/models/address_number.rb +0 -0
- data/spec/{app → support}/models/agency.rb +0 -0
- data/spec/{app → support}/models/agent.rb +0 -0
- data/spec/{app → support}/models/album.rb +0 -0
- data/spec/{app → support}/models/alert.rb +0 -0
- data/spec/{app → support}/models/animal.rb +0 -0
- data/spec/{app → support}/models/answer.rb +0 -0
- data/spec/{app → support}/models/appointment.rb +0 -0
- data/spec/support/models/armrest.rb +10 -0
- data/spec/{app → support}/models/array_field.rb +0 -0
- data/spec/{app → support}/models/article.rb +0 -0
- data/spec/{app → support}/models/artist.rb +0 -0
- data/spec/{app → support}/models/artwork.rb +0 -0
- data/spec/{app → support}/models/audio.rb +0 -0
- data/spec/{app → support}/models/augmentation.rb +0 -0
- data/spec/{app → support}/models/author.rb +0 -0
- data/spec/{app → support}/models/baby.rb +0 -0
- data/spec/{app → support}/models/band.rb +0 -0
- data/spec/{app → support}/models/bar.rb +0 -0
- data/spec/{app → support}/models/basic.rb +0 -0
- data/spec/{app → support}/models/bed.rb +0 -0
- data/spec/{app → support}/models/big_palette.rb +0 -0
- data/spec/{app → support}/models/birthday.rb +0 -0
- data/spec/{app → support}/models/bomb.rb +0 -0
- data/spec/{app → support}/models/book.rb +0 -0
- data/spec/{app → support}/models/breed.rb +0 -0
- data/spec/{app → support}/models/browser.rb +1 -1
- data/spec/{app → support}/models/building.rb +0 -0
- data/spec/{app → support}/models/building_address.rb +0 -0
- data/spec/{app → support}/models/bus.rb +0 -0
- data/spec/{app → support}/models/business.rb +0 -0
- data/spec/{app → support}/models/callback_test.rb +0 -0
- data/spec/{app → support}/models/canvas.rb +1 -1
- data/spec/{app → support}/models/car.rb +0 -0
- data/spec/{app → support}/models/cat.rb +0 -0
- data/spec/{app → support}/models/category.rb +0 -0
- data/spec/{app → support}/models/child.rb +0 -0
- data/spec/{app → support}/models/child_doc.rb +0 -0
- data/spec/{app → support}/models/church.rb +0 -0
- data/spec/{app → support}/models/circle.rb +0 -0
- data/spec/{app → support}/models/circuit.rb +0 -0
- data/spec/{app → support}/models/circus.rb +0 -0
- data/spec/{app → support}/models/code.rb +0 -0
- data/spec/support/models/coding.rb +4 -0
- data/spec/support/models/coding/pull_request.rb +12 -0
- data/spec/{app → support}/models/comment.rb +0 -0
- data/spec/{app → support}/models/company.rb +0 -0
- data/spec/{app → support}/models/consumption_period.rb +0 -0
- data/spec/{app → support}/models/contextable_item.rb +0 -0
- data/spec/{app → support}/models/contractor.rb +0 -0
- data/spec/{app → support}/models/cookie.rb +0 -0
- data/spec/{app → support}/models/country_code.rb +0 -0
- data/spec/{app → support}/models/courier_job.rb +0 -0
- data/spec/support/models/crate.rb +13 -0
- data/spec/support/models/deed.rb +8 -0
- data/spec/{app → support}/models/definition.rb +0 -0
- data/spec/support/models/delegating_patient.rb +16 -0
- data/spec/{app → support}/models/description.rb +0 -0
- data/spec/{app → support}/models/dictionary.rb +0 -0
- data/spec/{app → support}/models/division.rb +0 -0
- data/spec/{app → support}/models/doctor.rb +0 -0
- data/spec/{app → support}/models/dog.rb +0 -0
- data/spec/{app → support}/models/dokument.rb +0 -0
- data/spec/{app → support}/models/draft.rb +0 -0
- data/spec/{app → support}/models/dragon.rb +0 -0
- data/spec/{app → support}/models/driver.rb +1 -1
- data/spec/{app → support}/models/drug.rb +0 -0
- data/spec/{app → support}/models/dungeon.rb +0 -0
- data/spec/{app → support}/models/edit.rb +0 -0
- data/spec/{app → support}/models/email.rb +0 -0
- data/spec/{app → support}/models/employer.rb +0 -0
- data/spec/{app → support}/models/entry.rb +0 -0
- data/spec/{app → support}/models/eraser.rb +0 -0
- data/spec/{app → support}/models/even.rb +0 -0
- data/spec/{app → support}/models/event.rb +0 -0
- data/spec/{app → support}/models/exhibition.rb +0 -0
- data/spec/{app → support}/models/exhibitor.rb +0 -0
- data/spec/{app → support}/models/explosion.rb +0 -0
- data/spec/{app → support}/models/eye.rb +0 -0
- data/spec/{app → support}/models/eye_bowl.rb +0 -0
- data/spec/{app → support}/models/face.rb +0 -0
- data/spec/{app → support}/models/favorite.rb +0 -0
- data/spec/{app → support}/models/filesystem.rb +0 -0
- data/spec/{app → support}/models/fire_hydrant.rb +0 -0
- data/spec/{app → support}/models/firefox.rb +0 -0
- data/spec/{app → support}/models/fish.rb +0 -0
- data/spec/{app → support}/models/folder.rb +0 -0
- data/spec/{app → support}/models/folder_item.rb +0 -0
- data/spec/{app → support}/models/fruits.rb +0 -0
- data/spec/{app → support}/models/game.rb +0 -0
- data/spec/{app → support}/models/ghost.rb +0 -0
- data/spec/support/models/guitar.rb +5 -0
- data/spec/{app → support}/models/home.rb +0 -0
- data/spec/{app → support}/models/house.rb +0 -0
- data/spec/{app → support}/models/html_writer.rb +0 -0
- data/spec/{app → support}/models/id_key.rb +0 -0
- data/spec/support/models/idnodef.rb +8 -0
- data/spec/{app → support}/models/image.rb +0 -0
- data/spec/{app → support}/models/implant.rb +0 -0
- data/spec/support/models/instrument.rb +9 -0
- data/spec/{app → support}/models/item.rb +1 -1
- data/spec/{app → support}/models/jar.rb +0 -0
- data/spec/{app → support}/models/kaleidoscope.rb +0 -0
- data/spec/{app → support}/models/kangaroo.rb +0 -0
- data/spec/{app → support}/models/label.rb +0 -0
- data/spec/{app → support}/models/language.rb +0 -0
- data/spec/{app → support}/models/lat_lng.rb +0 -0
- data/spec/{app → support}/models/league.rb +0 -0
- data/spec/{app → support}/models/learner.rb +0 -0
- data/spec/{app → support}/models/line_item.rb +0 -0
- data/spec/{app → support}/models/location.rb +0 -0
- data/spec/{app → support}/models/login.rb +0 -0
- data/spec/{app → support}/models/manufacturer.rb +0 -0
- data/spec/{app → support}/models/meat.rb +0 -0
- data/spec/{app → support}/models/membership.rb +0 -0
- data/spec/{app → support}/models/message.rb +0 -0
- data/spec/{app → support}/models/minim.rb +0 -0
- data/spec/{app → support}/models/mixed_drink.rb +0 -0
- data/spec/support/models/mop.rb +16 -0
- data/spec/{app → support}/models/movie.rb +0 -0
- data/spec/{app → support}/models/my_hash.rb +0 -0
- data/spec/{app → support}/models/name.rb +0 -0
- data/spec/{app → support}/models/name_only.rb +0 -0
- data/spec/{app → support}/models/node.rb +0 -0
- data/spec/{app → support}/models/note.rb +0 -0
- data/spec/{app → support}/models/odd.rb +0 -0
- data/spec/{app → support}/models/ordered_post.rb +0 -0
- data/spec/{app → support}/models/ordered_preference.rb +0 -0
- data/spec/{app → support}/models/oscar.rb +0 -0
- data/spec/{app → support}/models/other_owner_object.rb +0 -0
- data/spec/{app → support}/models/override.rb +0 -0
- data/spec/{app → support}/models/ownable.rb +0 -0
- data/spec/{app → support}/models/owner.rb +2 -0
- data/spec/{app → support}/models/pack.rb +0 -0
- data/spec/{app → support}/models/page.rb +0 -0
- data/spec/{app → support}/models/page_question.rb +0 -0
- data/spec/{app → support}/models/palette.rb +1 -1
- data/spec/{app → support}/models/parent.rb +0 -0
- data/spec/{app → support}/models/parent_doc.rb +0 -0
- data/spec/{app → support}/models/passport.rb +1 -0
- data/spec/{app → support}/models/patient.rb +0 -0
- data/spec/{app → support}/models/pdf_writer.rb +0 -0
- data/spec/{app → support}/models/pencil.rb +0 -0
- data/spec/{app → support}/models/person.rb +1 -1
- data/spec/{app → support}/models/pet.rb +0 -0
- data/spec/{app → support}/models/pet_owner.rb +0 -0
- data/spec/{app → support}/models/phone.rb +1 -0
- data/spec/support/models/piano.rb +5 -0
- data/spec/{app → support}/models/pizza.rb +0 -0
- data/spec/{app → support}/models/player.rb +0 -0
- data/spec/{app → support}/models/post.rb +0 -0
- data/spec/{app → support}/models/post_genre.rb +0 -0
- data/spec/{app → support}/models/powerup.rb +0 -0
- data/spec/{app → support}/models/preference.rb +0 -0
- data/spec/{app → support}/models/princess.rb +0 -0
- data/spec/{app → support}/models/product.rb +0 -0
- data/spec/support/models/profile.rb +18 -0
- data/spec/{app → support}/models/pronunciation.rb +0 -0
- data/spec/{app → support}/models/pub.rb +0 -0
- data/spec/support/models/publication.rb +5 -0
- data/spec/support/models/publication/encyclopedia.rb +12 -0
- data/spec/support/models/publication/review.rb +14 -0
- data/spec/{app → support}/models/purchase.rb +0 -0
- data/spec/{app → support}/models/question.rb +0 -0
- data/spec/{app → support}/models/quiz.rb +0 -0
- data/spec/{app → support}/models/rating.rb +0 -0
- data/spec/{app → support}/models/record.rb +0 -0
- data/spec/{app → support}/models/registry.rb +0 -0
- data/spec/{app → support}/models/role.rb +0 -0
- data/spec/{app → support}/models/root_category.rb +0 -0
- data/spec/{app → support}/models/sandwich.rb +0 -0
- data/spec/{app → support}/models/scheduler.rb +0 -0
- data/spec/{app/models/profile.rb → support/models/scribe.rb} +2 -2
- data/spec/support/models/seat.rb +25 -0
- data/spec/{app → support}/models/seo.rb +0 -0
- data/spec/{app → support}/models/series.rb +0 -0
- data/spec/{app → support}/models/server.rb +0 -0
- data/spec/{app → support}/models/service.rb +0 -0
- data/spec/{app → support}/models/shape.rb +2 -2
- data/spec/{app → support}/models/shelf.rb +0 -0
- data/spec/{app → support}/models/shipment_address.rb +0 -0
- data/spec/{app → support}/models/shipping_container.rb +0 -0
- data/spec/{app → support}/models/shipping_pack.rb +0 -0
- data/spec/{app → support}/models/shop.rb +0 -0
- data/spec/{app → support}/models/short_agent.rb +0 -0
- data/spec/{app → support}/models/short_quiz.rb +0 -0
- data/spec/{app → support}/models/simple.rb +0 -0
- data/spec/{app → support}/models/slave.rb +0 -0
- data/spec/{app → support}/models/song.rb +0 -0
- data/spec/{app → support}/models/sound.rb +0 -0
- data/spec/{app → support}/models/square.rb +0 -0
- data/spec/{app → support}/models/staff.rb +0 -0
- data/spec/{app → support}/models/store_as_dup_test1.rb +0 -0
- data/spec/{app → support}/models/store_as_dup_test2.rb +0 -0
- data/spec/{app → support}/models/store_as_dup_test3.rb +0 -0
- data/spec/{app → support}/models/store_as_dup_test4.rb +0 -0
- data/spec/{app → support}/models/strategy.rb +0 -0
- data/spec/{app → support}/models/sub_item.rb +0 -0
- data/spec/{app → support}/models/subscription.rb +0 -0
- data/spec/{app → support}/models/survey.rb +0 -0
- data/spec/{app → support}/models/symptom.rb +0 -0
- data/spec/support/models/system_role.rb +7 -0
- data/spec/{app → support}/models/tag.rb +0 -0
- data/spec/{app → support}/models/target.rb +0 -0
- data/spec/{app → support}/models/template.rb +0 -0
- data/spec/{app → support}/models/thing.rb +0 -0
- data/spec/{app → support}/models/title.rb +0 -0
- data/spec/{app → support}/models/tool.rb +2 -2
- data/spec/{app → support}/models/topping.rb +0 -0
- data/spec/support/models/toy.rb +10 -0
- data/spec/{app → support}/models/track.rb +0 -0
- data/spec/{app → support}/models/translation.rb +0 -0
- data/spec/{app → support}/models/tree.rb +0 -0
- data/spec/{app → support}/models/truck.rb +2 -0
- data/spec/{app → support}/models/updatable.rb +0 -0
- data/spec/{app → support}/models/user.rb +0 -0
- data/spec/{app → support}/models/user_account.rb +0 -0
- data/spec/{app → support}/models/validation_callback.rb +0 -0
- data/spec/{app → support}/models/vehicle.rb +7 -2
- data/spec/{app → support}/models/version.rb +0 -0
- data/spec/{app → support}/models/vertex.rb +0 -0
- data/spec/{app → support}/models/vet_visit.rb +0 -0
- data/spec/{app → support}/models/video.rb +0 -0
- data/spec/{app → support}/models/video_game.rb +0 -0
- data/spec/{app → support}/models/weapon.rb +0 -0
- data/spec/{app → support}/models/wiki_page.rb +0 -0
- data/spec/{app → support}/models/word.rb +0 -0
- data/spec/{app → support}/models/word_origin.rb +0 -0
- data/spec/{app → support}/models/writer.rb +2 -2
- data/spec/support/session_registry.rb +50 -0
- data/spec/support/spec_config.rb +13 -5
- data/spec/support/spec_organizer.rb +130 -0
- metadata +882 -752
- metadata.gz.sig +0 -0
- data/lib/mongoid/matchable/all.rb +0 -30
- data/lib/mongoid/matchable/and.rb +0 -32
- data/lib/mongoid/matchable/default.rb +0 -121
- data/lib/mongoid/matchable/elem_match.rb +0 -36
- data/lib/mongoid/matchable/eq.rb +0 -23
- data/lib/mongoid/matchable/exists.rb +0 -25
- data/lib/mongoid/matchable/gt.rb +0 -25
- data/lib/mongoid/matchable/gte.rb +0 -25
- data/lib/mongoid/matchable/in.rb +0 -26
- data/lib/mongoid/matchable/lt.rb +0 -25
- data/lib/mongoid/matchable/lte.rb +0 -25
- data/lib/mongoid/matchable/ne.rb +0 -23
- data/lib/mongoid/matchable/nin.rb +0 -24
- data/lib/mongoid/matchable/nor.rb +0 -38
- data/lib/mongoid/matchable/or.rb +0 -35
- data/lib/mongoid/matchable/regexp.rb +0 -30
- data/lib/mongoid/matchable/size.rb +0 -23
- data/spec/mongoid/matchable/all_spec.rb +0 -34
- data/spec/mongoid/matchable/and_spec.rb +0 -190
- data/spec/mongoid/matchable/default_spec.rb +0 -140
- data/spec/mongoid/matchable/elem_match_spec.rb +0 -109
- data/spec/mongoid/matchable/eq_spec.rb +0 -49
- data/spec/mongoid/matchable/exists_spec.rb +0 -60
- data/spec/mongoid/matchable/gt_spec.rb +0 -89
- data/spec/mongoid/matchable/gte_spec.rb +0 -87
- data/spec/mongoid/matchable/in_spec.rb +0 -52
- data/spec/mongoid/matchable/lt_spec.rb +0 -88
- data/spec/mongoid/matchable/lte_spec.rb +0 -88
- data/spec/mongoid/matchable/ne_spec.rb +0 -49
- data/spec/mongoid/matchable/nin_spec.rb +0 -51
- data/spec/mongoid/matchable/nor_spec.rb +0 -210
- data/spec/mongoid/matchable/or_spec.rb +0 -134
- data/spec/mongoid/matchable/regexp_spec.rb +0 -62
- data/spec/mongoid/matchable/size_spec.rb +0 -28
- data/spec/mongoid/matchable_spec.rb +0 -856
@@ -12,8 +12,6 @@ module Mongoid
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def preload
|
15
|
-
raise Errors::EagerLoad.new(@association.name) if @association.polymorphic?
|
16
|
-
|
17
15
|
@docs.each do |d|
|
18
16
|
set_relation(d, nil)
|
19
17
|
end
|
@@ -24,6 +22,44 @@ module Mongoid
|
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
25
|
+
# Retrieves the documents referenced by the association, and
|
26
|
+
# yields each one sequentially to the provided block. If the
|
27
|
+
# association is not polymorphic, all documents are retrieved in
|
28
|
+
# a single query. If the association is polymorphic, one query is
|
29
|
+
# issued per association target class.
|
30
|
+
def each_loaded_document(&block)
|
31
|
+
if @association.polymorphic?
|
32
|
+
keys_by_type_from_docs.each do |type, keys|
|
33
|
+
each_loaded_document_of_class(Object.const_get(type), keys, &block)
|
34
|
+
end
|
35
|
+
else
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns a map from association target class name to foreign key
|
41
|
+
# values for the documents of that association target class,
|
42
|
+
# as referenced by this association.
|
43
|
+
def keys_by_type_from_docs
|
44
|
+
inverse_type_field = @association.inverse_type
|
45
|
+
|
46
|
+
@docs.each_with_object({}) do |doc, keys_by_type|
|
47
|
+
next unless doc.respond_to?(inverse_type_field) && doc.respond_to?(group_by_key)
|
48
|
+
inverse_type_name = doc.send(inverse_type_field)
|
49
|
+
# If a particular document does not have a value for this
|
50
|
+
# association, inverse_type_name will be nil.
|
51
|
+
next if inverse_type_name.nil?
|
52
|
+
|
53
|
+
key_value = doc.send(group_by_key)
|
54
|
+
# If a document has the *_type field set but the corresponding
|
55
|
+
# *_id field not set, the key value here will be nil.
|
56
|
+
next unless key_value
|
57
|
+
|
58
|
+
keys_by_type[inverse_type_name] ||= []
|
59
|
+
keys_by_type[inverse_type_name].push(key_value)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
27
63
|
def group_by_key
|
28
64
|
@association.foreign_key
|
29
65
|
end
|
@@ -59,17 +59,29 @@ module Mongoid
|
|
59
59
|
raise NotImplementedError
|
60
60
|
end
|
61
61
|
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
62
|
+
# Retrieves the documents referenced by the association, and
|
63
|
+
# yields each one sequentially to the provided block. If the
|
64
|
+
# association is not polymorphic, all documents are retrieved in
|
65
|
+
# a single query. If the association is polymorphic, one query is
|
66
|
+
# issued per association target class.
|
66
67
|
#
|
67
68
|
# @since 4.0.0
|
68
|
-
def each_loaded_document
|
69
|
-
|
70
|
-
|
69
|
+
def each_loaded_document(&block)
|
70
|
+
each_loaded_document_of_class(@association.klass, keys_from_docs, &block)
|
71
|
+
end
|
71
72
|
|
72
|
-
|
73
|
+
# Retrieves the documents of the specified class, that have the
|
74
|
+
# foreign key included in the specified list of keys.
|
75
|
+
#
|
76
|
+
# When the documents are retrieved, the set of inclusions applied
|
77
|
+
# is the set of inclusions applied to the host document minus the
|
78
|
+
# association that is being eagerly loaded.
|
79
|
+
private def each_loaded_document_of_class(cls, keys)
|
80
|
+
# Note: keys should not include nil elements.
|
81
|
+
# Upstream code is responsible for eliminating nils from keys.
|
82
|
+
return cls.none if keys.empty?
|
83
|
+
|
84
|
+
criteria = cls.any_in(key => keys)
|
73
85
|
criteria.inclusions = criteria.inclusions - [@association]
|
74
86
|
criteria.each do |doc|
|
75
87
|
yield doc
|
@@ -93,6 +105,9 @@ module Mongoid
|
|
93
105
|
|
94
106
|
# Return a hash with the current documents grouped by key.
|
95
107
|
#
|
108
|
+
# Documents that do not have a value for the association being loaded
|
109
|
+
# are not returned.
|
110
|
+
#
|
96
111
|
# @example Return a hash with the current documents grouped by key.
|
97
112
|
# loader.grouped_docs
|
98
113
|
#
|
@@ -102,10 +117,15 @@ module Mongoid
|
|
102
117
|
def grouped_docs
|
103
118
|
@grouped_docs[@association.name] ||= @docs.group_by do |doc|
|
104
119
|
doc.send(group_by_key) if doc.respond_to?(group_by_key)
|
120
|
+
end.reject do |k, v|
|
121
|
+
k.nil?
|
105
122
|
end
|
106
123
|
end
|
107
124
|
|
108
|
-
# Group the documents and return the keys
|
125
|
+
# Group the documents and return the keys.
|
126
|
+
#
|
127
|
+
# This method omits nil keys (i.e. keys from documents that do not
|
128
|
+
# have a value for the association being loaded).
|
109
129
|
#
|
110
130
|
# @example
|
111
131
|
# loader.keys_from_docs
|
@@ -101,7 +101,7 @@ module Mongoid
|
|
101
101
|
|
102
102
|
# Delete the document from the association. This will set the foreign key
|
103
103
|
# on the document to nil. If the dependent options on the association are
|
104
|
-
# :
|
104
|
+
# :delete_all or :destroy the appropriate removal will occur.
|
105
105
|
#
|
106
106
|
# @example Delete the document.
|
107
107
|
# person.posts.delete(post)
|
@@ -11,6 +11,7 @@ module Mongoid
|
|
11
11
|
# target that can be a criteria or array of _loaded documents. This
|
12
12
|
# handles both cases or a combination of the two.
|
13
13
|
class Enumerable
|
14
|
+
extend Forwardable
|
14
15
|
include ::Enumerable
|
15
16
|
|
16
17
|
# The three main instance variables are collections of documents.
|
@@ -20,7 +21,7 @@ module Mongoid
|
|
20
21
|
# @attribute [rw] _unloaded A criteria representing persisted docs.
|
21
22
|
attr_accessor :_added, :_loaded, :_unloaded
|
22
23
|
|
23
|
-
|
24
|
+
def_delegators [], :is_a?, :kind_of?
|
24
25
|
|
25
26
|
# Check if the enumerable is equal to the other object.
|
26
27
|
#
|
@@ -215,25 +216,38 @@ module Mongoid
|
|
215
216
|
end
|
216
217
|
end
|
217
218
|
|
218
|
-
#
|
219
|
-
#
|
219
|
+
# Returns whether the association has any documents, optionally
|
220
|
+
# subject to the provided filters.
|
220
221
|
#
|
221
|
-
#
|
222
|
-
#
|
222
|
+
# This method returns true if the association has any persisted
|
223
|
+
# documents and if it has any not yet persisted documents.
|
223
224
|
#
|
224
|
-
#
|
225
|
+
# If the association is already loaded, this method inspects the
|
226
|
+
# loaded documents and does not query the database. If the
|
227
|
+
# association is not loaded, the argument-less and block-less
|
228
|
+
# version does not load the association; the other versions
|
229
|
+
# (that delegate to Enumerable) may or may not load the association
|
230
|
+
# completely depending on whether it is iterated to completion.
|
225
231
|
#
|
226
|
-
#
|
232
|
+
# This method can take a parameter and a block. The behavior with
|
233
|
+
# either the paramater or the block is delegated to the standard
|
234
|
+
# library Enumerable module.
|
227
235
|
#
|
228
|
-
#
|
236
|
+
# Note that when Enumerable's any? method is invoked with both
|
237
|
+
# a block and a pattern, it only uses the pattern.
|
229
238
|
#
|
230
|
-
# @
|
239
|
+
# @param [ Object ] condition The condition that documents
|
240
|
+
# must satisfy. See Enumerable documentation for details.
|
231
241
|
#
|
232
|
-
# @
|
233
|
-
def
|
234
|
-
|
235
|
-
|
236
|
-
|
242
|
+
# @return [ true, false ] If the association has any documents.
|
243
|
+
def any?(*args)
|
244
|
+
return super if args.any? || block_given?
|
245
|
+
|
246
|
+
if _loaded?
|
247
|
+
in_memory.length > 0
|
248
|
+
else
|
249
|
+
_unloaded.exists? || _added.length > 0
|
250
|
+
end
|
237
251
|
end
|
238
252
|
|
239
253
|
# Get the first document in the enumerable. Will check the persisted
|
@@ -415,7 +429,8 @@ module Mongoid
|
|
415
429
|
#
|
416
430
|
# @since 2.1.0
|
417
431
|
def reset
|
418
|
-
_loaded.clear
|
432
|
+
_loaded.clear
|
433
|
+
_added.clear
|
419
434
|
@executed = false
|
420
435
|
end
|
421
436
|
|
@@ -9,9 +9,10 @@ module Mongoid
|
|
9
9
|
# This class defines the behavior for all associations that are a
|
10
10
|
# one-to-many between documents in different collections.
|
11
11
|
class Proxy < Association::Many
|
12
|
+
extend Forwardable
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
def_delegator :criteria, :count
|
15
|
+
def_delegators :_target, :first, :in_memory, :last, :reset, :uniq
|
15
16
|
|
16
17
|
# Appends a document or array of documents to the association. Will set
|
17
18
|
# the parent and update the index in the process.
|
@@ -89,7 +90,7 @@ module Mongoid
|
|
89
90
|
|
90
91
|
# Delete the document from the association. This will set the foreign key
|
91
92
|
# on the document to nil. If the dependent options on the association are
|
92
|
-
# :
|
93
|
+
# :delete_all or :destroy the appropriate removal will occur.
|
93
94
|
#
|
94
95
|
# @example Delete the document.
|
95
96
|
# person.posts.delete(post)
|
@@ -169,6 +170,13 @@ module Mongoid
|
|
169
170
|
|
170
171
|
# Determine if any documents in this association exist in the database.
|
171
172
|
#
|
173
|
+
# If the association contains documents but all of the documents
|
174
|
+
# exist only in the application, i.e. have not been persisted to the
|
175
|
+
# database, this method returns false.
|
176
|
+
#
|
177
|
+
# This method queries the database on each invocation even if the
|
178
|
+
# association is already loaded into memory.
|
179
|
+
#
|
172
180
|
# @example Are there persisted documents?
|
173
181
|
# person.posts.exists?
|
174
182
|
#
|
data/lib/mongoid/atomic.rb
CHANGED
@@ -38,7 +38,9 @@ module Mongoid
|
|
38
38
|
# @since 2.2.0
|
39
39
|
def add_atomic_pull(document)
|
40
40
|
document.flagged_for_destroy = true
|
41
|
-
|
41
|
+
key = document.association_name.to_s
|
42
|
+
delayed_atomic_pulls[key] ||= []
|
43
|
+
delayed_atomic_pulls[key] << document
|
42
44
|
end
|
43
45
|
|
44
46
|
# Add an atomic unset for the document.
|
@@ -53,7 +55,9 @@ module Mongoid
|
|
53
55
|
# @since 3.0.0
|
54
56
|
def add_atomic_unset(document)
|
55
57
|
document.flagged_for_destroy = true
|
56
|
-
|
58
|
+
key = document.association_name.to_s
|
59
|
+
delayed_atomic_unsets[key] ||= []
|
60
|
+
delayed_atomic_unsets[key] << document
|
57
61
|
end
|
58
62
|
|
59
63
|
# Returns path of the attribute for modification
|
@@ -191,7 +195,13 @@ module Mongoid
|
|
191
195
|
#
|
192
196
|
# @since 2.1.0
|
193
197
|
def atomic_paths
|
194
|
-
@atomic_paths ||=
|
198
|
+
@atomic_paths ||= begin
|
199
|
+
if _association
|
200
|
+
_association.path(self)
|
201
|
+
else
|
202
|
+
Atomic::Paths::Root.new(self)
|
203
|
+
end
|
204
|
+
end
|
195
205
|
end
|
196
206
|
|
197
207
|
# Get all the attributes that need to be pulled.
|
@@ -193,7 +193,7 @@ module Mongoid
|
|
193
193
|
def push_conflict?(field)
|
194
194
|
name = field.split(".", 2)[0]
|
195
195
|
set_fields.has_key?(name) || pull_fields.has_key?(name) ||
|
196
|
-
(push_fields.keys.count { |item| item
|
196
|
+
(push_fields.keys.count { |item| item.split('.', 2).first == name } > 1)
|
197
197
|
end
|
198
198
|
|
199
199
|
# Get the conflicting pull modifications.
|
data/lib/mongoid/attributes.rb
CHANGED
@@ -159,21 +159,21 @@ module Mongoid
|
|
159
159
|
#
|
160
160
|
# @since 1.0.0
|
161
161
|
def write_attribute(name, value)
|
162
|
-
|
163
|
-
if attribute_writable?(
|
162
|
+
field_name = database_field_name(name)
|
163
|
+
if attribute_writable?(field_name)
|
164
164
|
_assigning do
|
165
|
-
validate_attribute_value(
|
166
|
-
localized = fields[
|
165
|
+
validate_attribute_value(field_name, value)
|
166
|
+
localized = fields[field_name].try(:localized?)
|
167
167
|
attributes_before_type_cast[name.to_s] = value
|
168
|
-
typed_value = typed_value_for(
|
169
|
-
unless attributes[
|
170
|
-
attribute_will_change!(
|
168
|
+
typed_value = typed_value_for(field_name, value)
|
169
|
+
unless attributes[field_name] == typed_value || attribute_changed?(field_name)
|
170
|
+
attribute_will_change!(field_name)
|
171
171
|
end
|
172
172
|
if localized
|
173
|
-
attributes[
|
174
|
-
attributes[
|
173
|
+
attributes[field_name] ||= {}
|
174
|
+
attributes[field_name].merge!(typed_value)
|
175
175
|
else
|
176
|
-
attributes[
|
176
|
+
attributes[field_name] = typed_value
|
177
177
|
end
|
178
178
|
typed_value
|
179
179
|
end
|
@@ -338,20 +338,28 @@ module Mongoid
|
|
338
338
|
|
339
339
|
private
|
340
340
|
|
341
|
-
# Validates an attribute value
|
342
|
-
# the value is valid for given a field.
|
343
|
-
# For now, only Hash and Array fields are validated.
|
341
|
+
# Validates an attribute value as being assignable to the specified field.
|
344
342
|
#
|
345
|
-
#
|
346
|
-
#
|
343
|
+
# For now, only Hash and Array fields are validated, and the value is
|
344
|
+
# being checked to be of an appropriate type (i.e. either Hash or Array,
|
345
|
+
# respectively, or nil).
|
346
|
+
#
|
347
|
+
# This method takes the name of the field as stored in the document
|
348
|
+
# in the database, not (necessarily) the Ruby method name used to read/write
|
349
|
+
# the said field.
|
350
|
+
#
|
351
|
+
# @param [ String, Symbol ] field_name The name of the field.
|
352
|
+
# @param [ Object ] value The value to be validated.
|
347
353
|
#
|
348
354
|
# @since 3.0.10
|
349
|
-
def validate_attribute_value(
|
350
|
-
return
|
355
|
+
def validate_attribute_value(field_name, value)
|
356
|
+
return if value.nil?
|
357
|
+
field = fields[field_name]
|
358
|
+
return unless field
|
351
359
|
validatable_types = [ Hash, Array ]
|
352
|
-
if validatable_types.include?
|
353
|
-
unless value.is_a?
|
354
|
-
raise Mongoid::Errors::InvalidValue.new(
|
360
|
+
if validatable_types.include?(field.type)
|
361
|
+
unless value.is_a?(field.type)
|
362
|
+
raise Mongoid::Errors::InvalidValue.new(field.type, value.class)
|
355
363
|
end
|
356
364
|
end
|
357
365
|
end
|
@@ -116,7 +116,7 @@ module Mongoid
|
|
116
116
|
#
|
117
117
|
# @since 4.0.0
|
118
118
|
def inspect_dynamic_fields
|
119
|
-
keys = attributes.keys - fields.keys - relations.keys - ["_id",
|
119
|
+
keys = attributes.keys - fields.keys - relations.keys - ["_id", self.class.discriminator_key]
|
120
120
|
return keys.map do |name|
|
121
121
|
"#{name}: #{attributes[name].inspect}"
|
122
122
|
end
|
@@ -12,9 +12,9 @@ module Mongoid
|
|
12
12
|
# raised.
|
13
13
|
#
|
14
14
|
# @example Create the client.
|
15
|
-
# Factory.create(:
|
15
|
+
# Factory.create(:analytics)
|
16
16
|
#
|
17
|
-
# @param [ String
|
17
|
+
# @param [ String | Symbol ] name The named client configuration.
|
18
18
|
#
|
19
19
|
# @raise [ Errors::NoClientConfig ] If no config could be found.
|
20
20
|
#
|
@@ -69,11 +69,28 @@ module Mongoid
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
MONGOID_WRAPPING_LIBRARY = {
|
73
|
+
name: 'Mongoid',
|
74
|
+
version: VERSION,
|
75
|
+
}.freeze
|
76
|
+
|
77
|
+
def driver_version
|
78
|
+
Mongo::VERSION.split('.')[0...2].map(&:to_i)
|
79
|
+
end
|
80
|
+
|
72
81
|
def options(configuration)
|
73
82
|
config = configuration.dup
|
74
83
|
options = config.delete(:options) || {}
|
75
84
|
options[:platform] = PLATFORM_DETAILS
|
76
85
|
options[:app_name] = Mongoid::Config.app_name if Mongoid::Config.app_name
|
86
|
+
if (driver_version <=> [2, 13]) >= 0
|
87
|
+
wrap_lib = if options[:wrapping_libraries]
|
88
|
+
[MONGOID_WRAPPING_LIBRARY] + options[:wrapping_libraries]
|
89
|
+
else
|
90
|
+
[MONGOID_WRAPPING_LIBRARY]
|
91
|
+
end
|
92
|
+
options[:wrapping_libraries] = wrap_lib
|
93
|
+
end
|
77
94
|
options.reject{ |k, v| k == :hosts }.to_hash.symbolize_keys!
|
78
95
|
end
|
79
96
|
end
|
@@ -9,16 +9,16 @@ module Mongoid
|
|
9
9
|
# Change the persistence context for this object during the block.
|
10
10
|
#
|
11
11
|
# @example Save the current document to a different collection.
|
12
|
-
# model.with(collection: "
|
12
|
+
# model.with(collection: "bands") do |m|
|
13
13
|
# m.save
|
14
14
|
# end
|
15
15
|
#
|
16
16
|
# @param [ Hash, Mongoid::PersistenceContext ] options_or_context
|
17
17
|
# The storage options or a persistence context.
|
18
18
|
#
|
19
|
-
# @option options [ String
|
20
|
-
# @option options [ String
|
21
|
-
# @option options [ String
|
19
|
+
# @option options [ String | Symbol ] :collection The collection name.
|
20
|
+
# @option options [ String | Symbol ] :database The database name.
|
21
|
+
# @option options [ String | Symbol ] :client The client name.
|
22
22
|
#
|
23
23
|
# @since 6.0.0
|
24
24
|
def with(options_or_context, &block)
|
@@ -83,15 +83,15 @@ module Mongoid
|
|
83
83
|
# Change the persistence context for this class during the block.
|
84
84
|
#
|
85
85
|
# @example Save the current document to a different collection.
|
86
|
-
# Model.with(collection: "
|
86
|
+
# Model.with(collection: "bands") do |m|
|
87
87
|
# m.create
|
88
88
|
# end
|
89
89
|
#
|
90
90
|
# @param [ Hash ] options The storage options.
|
91
91
|
#
|
92
|
-
# @option options [ String
|
93
|
-
# @option options [ String
|
94
|
-
# @option options [ String
|
92
|
+
# @option options [ String | Symbol ] :collection The collection name.
|
93
|
+
# @option options [ String | Symbol ] :database The database name.
|
94
|
+
# @option options [ String | Symbol ] :client The client name.
|
95
95
|
#
|
96
96
|
# @since 6.0.0
|
97
97
|
def with(options, &block)
|