mongoid 9.0.11 → 9.1.0
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 +8 -8
- data/README.md +5 -11
- data/Rakefile +35 -38
- data/lib/config/locales/en.yml +11 -0
- data/lib/mongoid/association/accessors.rb +19 -26
- data/lib/mongoid/association/bindable.rb +43 -45
- data/lib/mongoid/association/builders.rb +18 -15
- data/lib/mongoid/association/constrainable.rb +3 -5
- data/lib/mongoid/association/depending.rb +34 -38
- data/lib/mongoid/association/eager.rb +47 -13
- data/lib/mongoid/association/eager_loadable.rb +152 -24
- data/lib/mongoid/association/embedded/batchable.rb +28 -30
- data/lib/mongoid/association/embedded/cyclic.rb +8 -11
- data/lib/mongoid/association/embedded/eager.rb +1 -6
- data/lib/mongoid/association/embedded/embedded_in/binding.rb +6 -9
- data/lib/mongoid/association/embedded/embedded_in/buildable.rb +2 -3
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -0
- data/lib/mongoid/association/embedded/embedded_in.rb +25 -22
- data/lib/mongoid/association/embedded/embeds_many/binding.rb +0 -2
- data/lib/mongoid/association/embedded/embeds_many/buildable.rb +2 -3
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_many.rb +24 -21
- data/lib/mongoid/association/embedded/embeds_one/binding.rb +0 -2
- data/lib/mongoid/association/embedded/embeds_one/buildable.rb +2 -6
- data/lib/mongoid/association/embedded/embeds_one.rb +20 -18
- data/lib/mongoid/association/embedded.rb +0 -1
- data/lib/mongoid/association/macros.rb +3 -7
- data/lib/mongoid/association/many.rb +75 -3
- data/lib/mongoid/association/marshalable.rb +0 -3
- data/lib/mongoid/association/nested/many.rb +18 -13
- data/lib/mongoid/association/nested/nested_buildable.rb +6 -9
- data/lib/mongoid/association/nested/one.rb +4 -7
- data/lib/mongoid/association/nested.rb +1 -3
- data/lib/mongoid/association/one.rb +0 -3
- data/lib/mongoid/association/options.rb +8 -7
- data/lib/mongoid/association/referenced/auto_save.rb +0 -2
- data/lib/mongoid/association/referenced/belongs_to/binding.rb +11 -15
- data/lib/mongoid/association/referenced/belongs_to/buildable.rb +23 -5
- data/lib/mongoid/association/referenced/belongs_to/eager.rb +1 -3
- data/lib/mongoid/association/referenced/belongs_to.rb +48 -43
- data/lib/mongoid/association/referenced/counter_cache.rb +5 -10
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb +0 -2
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb +8 -4
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/eager.rb +0 -3
- data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +52 -47
- data/lib/mongoid/association/referenced/has_many/binding.rb +0 -2
- data/lib/mongoid/association/referenced/has_many/buildable.rb +11 -5
- data/lib/mongoid/association/referenced/has_many/eager.rb +0 -3
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +107 -38
- data/lib/mongoid/association/referenced/has_many/proxy.rb +10 -6
- data/lib/mongoid/association/referenced/has_many.rb +30 -24
- data/lib/mongoid/association/referenced/has_one/binding.rb +0 -2
- data/lib/mongoid/association/referenced/has_one/buildable.rb +11 -9
- data/lib/mongoid/association/referenced/has_one/eager.rb +0 -3
- data/lib/mongoid/association/referenced/has_one.rb +26 -21
- data/lib/mongoid/association/referenced/syncable.rb +30 -34
- data/lib/mongoid/association/referenced.rb +0 -1
- data/lib/mongoid/association/reflections.rb +0 -3
- data/lib/mongoid/association/relatable.rb +69 -66
- data/lib/mongoid/association.rb +12 -15
- data/lib/mongoid/atomic/modifiers.rb +65 -25
- data/lib/mongoid/atomic/paths/embedded/many.rb +4 -7
- data/lib/mongoid/atomic/paths/embedded/one.rb +2 -4
- data/lib/mongoid/atomic/paths/embedded.rb +3 -6
- data/lib/mongoid/atomic/paths/root.rb +1 -4
- data/lib/mongoid/atomic/paths.rb +2 -3
- data/lib/mongoid/atomic.rb +0 -3
- data/lib/mongoid/attributes/dynamic.rb +6 -7
- data/lib/mongoid/attributes/nested.rb +8 -10
- data/lib/mongoid/attributes/projector.rb +7 -20
- data/lib/mongoid/attributes/readonly.rb +6 -11
- data/lib/mongoid/attributes.rb +18 -34
- data/lib/mongoid/cacheable.rb +24 -6
- data/lib/mongoid/clients/factory.rb +12 -15
- data/lib/mongoid/clients/options.rb +2 -5
- data/lib/mongoid/clients/sessions.rb +50 -60
- data/lib/mongoid/clients/storage_options.rb +1 -4
- data/lib/mongoid/clients/validators/storage.rb +2 -3
- data/lib/mongoid/clients/validators.rb +1 -2
- data/lib/mongoid/clients.rb +8 -11
- data/lib/mongoid/collection_configurable.rb +10 -14
- data/lib/mongoid/composable.rb +30 -34
- data/lib/mongoid/config/defaults.rb +7 -4
- data/lib/mongoid/config/encryption.rb +1 -3
- data/lib/mongoid/config/environment.rb +7 -16
- data/lib/mongoid/config/introspection.rb +14 -16
- data/lib/mongoid/config/options.rb +16 -10
- data/lib/mongoid/config/validators/async_query_executor.rb +3 -6
- data/lib/mongoid/config/validators/client.rb +12 -15
- data/lib/mongoid/config/validators/option.rb +3 -5
- data/lib/mongoid/config/validators.rb +3 -4
- data/lib/mongoid/config.rb +132 -42
- data/lib/mongoid/contextual/aggregable/memory.rb +2 -4
- data/lib/mongoid/contextual/aggregable/mongo.rb +20 -22
- data/lib/mongoid/contextual/aggregable/none.rb +2 -4
- data/lib/mongoid/contextual/aggregable.rb +5 -7
- data/lib/mongoid/contextual/atomic.rb +20 -24
- data/lib/mongoid/contextual/command.rb +0 -3
- data/lib/mongoid/contextual/map_reduce.rb +12 -16
- data/lib/mongoid/contextual/memory.rb +72 -65
- data/lib/mongoid/contextual/mongo/documents_loader.rb +2 -3
- data/lib/mongoid/contextual/mongo.rb +169 -85
- data/lib/mongoid/contextual/none.rb +9 -9
- data/lib/mongoid/contextual/queryable.rb +1 -4
- data/lib/mongoid/contextual.rb +18 -7
- data/lib/mongoid/copyable.rb +7 -9
- data/lib/mongoid/criteria/findable.rb +5 -7
- data/lib/mongoid/criteria/includable.rb +37 -8
- data/lib/mongoid/criteria/inspectable.rb +2 -5
- data/lib/mongoid/criteria/marshalable.rb +4 -8
- data/lib/mongoid/criteria/modifiable.rb +3 -11
- data/lib/mongoid/criteria/options.rb +0 -3
- data/lib/mongoid/criteria/permission.rb +34 -37
- data/lib/mongoid/criteria/queryable/aggregable.rb +9 -10
- data/lib/mongoid/criteria/queryable/expandable.rb +4 -9
- data/lib/mongoid/criteria/queryable/extensions/array.rb +7 -10
- data/lib/mongoid/criteria/queryable/extensions/big_decimal.rb +3 -5
- data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -4
- data/lib/mongoid/criteria/queryable/extensions/date.rb +2 -6
- data/lib/mongoid/criteria/queryable/extensions/date_time.rb +3 -7
- data/lib/mongoid/criteria/queryable/extensions/hash.rb +1 -4
- data/lib/mongoid/criteria/queryable/extensions/nil_class.rb +20 -11
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +15 -11
- data/lib/mongoid/criteria/queryable/extensions/object.rb +7 -8
- data/lib/mongoid/criteria/queryable/extensions/range.rb +6 -9
- data/lib/mongoid/criteria/queryable/extensions/regexp.rb +10 -12
- data/lib/mongoid/criteria/queryable/extensions/set.rb +4 -6
- data/lib/mongoid/criteria/queryable/extensions/string.rb +5 -9
- data/lib/mongoid/criteria/queryable/extensions/symbol.rb +3 -7
- data/lib/mongoid/criteria/queryable/extensions/time.rb +2 -6
- data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +2 -12
- data/lib/mongoid/criteria/queryable/extensions.rb +18 -21
- data/lib/mongoid/criteria/queryable/key.rb +12 -18
- data/lib/mongoid/criteria/queryable/macroable.rb +0 -3
- data/lib/mongoid/criteria/queryable/mergeable.rb +31 -39
- data/lib/mongoid/criteria/queryable/optional.rb +17 -18
- data/lib/mongoid/criteria/queryable/options.rb +20 -9
- data/lib/mongoid/criteria/queryable/pipeline.rb +6 -9
- data/lib/mongoid/criteria/queryable/selectable.rb +131 -193
- data/lib/mongoid/criteria/queryable/selector.rb +20 -29
- data/lib/mongoid/criteria/queryable/smash.rb +1 -6
- data/lib/mongoid/criteria/queryable/storable.rb +20 -39
- data/lib/mongoid/criteria/queryable.rb +25 -15
- data/lib/mongoid/criteria/scopable.rb +5 -11
- data/lib/mongoid/criteria/translator.rb +5 -8
- data/lib/mongoid/criteria.rb +109 -54
- data/lib/mongoid/deprecable.rb +1 -4
- data/lib/mongoid/deprecation.rb +2 -6
- data/lib/mongoid/document.rb +1 -1
- data/lib/mongoid/encryptable.rb +1 -2
- data/lib/mongoid/equality.rb +4 -5
- data/lib/mongoid/errors/ambiguous_relationship.rb +2 -5
- data/lib/mongoid/errors/attribute_not_loaded.rb +1 -4
- data/lib/mongoid/errors/callback.rb +1 -4
- data/lib/mongoid/errors/create_collection_failure.rb +8 -11
- data/lib/mongoid/errors/criteria_argument_required.rb +2 -5
- data/lib/mongoid/errors/delete_restriction.rb +1 -4
- data/lib/mongoid/errors/document_not_destroyed.rb +1 -4
- data/lib/mongoid/errors/document_not_found.rb +16 -21
- data/lib/mongoid/errors/drop_collection_failure.rb +7 -10
- data/lib/mongoid/errors/empty_config_file.rb +1 -4
- data/lib/mongoid/errors/immutable_attribute.rb +1 -4
- data/lib/mongoid/errors/in_memory_collation_not_supported.rb +1 -4
- data/lib/mongoid/errors/invalid_async_query_executor.rb +2 -5
- data/lib/mongoid/errors/invalid_auto_encryption_configuration.rb +2 -5
- data/lib/mongoid/errors/invalid_collection.rb +1 -3
- data/lib/mongoid/errors/invalid_config_file.rb +1 -4
- data/lib/mongoid/errors/invalid_config_option.rb +2 -5
- data/lib/mongoid/errors/invalid_dependent_strategy.rb +6 -10
- data/lib/mongoid/errors/invalid_discriminator_key_target.rb +2 -4
- data/lib/mongoid/errors/invalid_dot_dollar_assignment.rb +1 -4
- data/lib/mongoid/errors/invalid_elem_match_operator.rb +5 -9
- data/lib/mongoid/errors/invalid_estimated_count_criteria.rb +1 -4
- data/lib/mongoid/errors/invalid_estimated_count_scoping.rb +1 -4
- data/lib/mongoid/errors/invalid_expression_operator.rb +3 -7
- data/lib/mongoid/errors/invalid_field.rb +2 -5
- data/lib/mongoid/errors/invalid_field_operator.rb +5 -9
- data/lib/mongoid/errors/invalid_field_option.rb +2 -5
- data/lib/mongoid/errors/invalid_field_type.rb +1 -4
- data/lib/mongoid/errors/invalid_find.rb +1 -4
- data/lib/mongoid/errors/invalid_global_executor_concurrency.rb +1 -4
- data/lib/mongoid/errors/invalid_includes.rb +3 -6
- data/lib/mongoid/errors/invalid_index.rb +1 -4
- data/lib/mongoid/errors/invalid_options.rb +1 -4
- data/lib/mongoid/errors/invalid_path.rb +1 -4
- data/lib/mongoid/errors/invalid_persistence_option.rb +4 -7
- data/lib/mongoid/errors/invalid_query.rb +6 -11
- data/lib/mongoid/errors/invalid_relation.rb +10 -13
- data/lib/mongoid/errors/invalid_relation_option.rb +4 -7
- data/lib/mongoid/errors/invalid_scope.rb +1 -4
- data/lib/mongoid/errors/invalid_session_nesting.rb +0 -3
- data/lib/mongoid/errors/invalid_set_polymorphic_relation.rb +2 -4
- data/lib/mongoid/errors/invalid_storage_options.rb +1 -4
- data/lib/mongoid/errors/invalid_time.rb +1 -4
- data/lib/mongoid/errors/invalid_transaction_nesting.rb +0 -3
- data/lib/mongoid/errors/inverse_not_found.rb +1 -4
- data/lib/mongoid/errors/mixed_client_configuration.rb +1 -4
- data/lib/mongoid/errors/mixed_relations.rb +1 -3
- data/lib/mongoid/errors/mongoid_error.rb +7 -11
- data/lib/mongoid/errors/nested_attributes_metadata_not_found.rb +1 -4
- data/lib/mongoid/errors/no_client_config.rb +1 -4
- data/lib/mongoid/errors/no_client_database.rb +1 -4
- data/lib/mongoid/errors/no_client_hosts.rb +1 -4
- data/lib/mongoid/errors/no_clients_config.rb +1 -4
- data/lib/mongoid/errors/no_default_client.rb +1 -4
- data/lib/mongoid/errors/no_environment.rb +1 -4
- data/lib/mongoid/errors/no_map_reduce_output.rb +1 -4
- data/lib/mongoid/errors/no_metadata.rb +1 -4
- data/lib/mongoid/errors/no_parent.rb +1 -4
- data/lib/mongoid/errors/readonly_attribute.rb +1 -4
- data/lib/mongoid/errors/readonly_document.rb +1 -4
- data/lib/mongoid/errors/rollback.rb +0 -2
- data/lib/mongoid/errors/scope_overwrite.rb +2 -4
- data/lib/mongoid/errors/sessions_not_supported.rb +0 -3
- data/lib/mongoid/errors/too_many_nested_attribute_records.rb +1 -3
- data/lib/mongoid/errors/transaction_error.rb +0 -3
- data/lib/mongoid/errors/transactions_not_supported.rb +0 -3
- data/lib/mongoid/errors/unknown_attribute.rb +1 -4
- data/lib/mongoid/errors/unknown_model.rb +1 -4
- data/lib/mongoid/errors/unregistered_class.rb +1 -1
- data/lib/mongoid/errors/unsaved_document.rb +1 -3
- data/lib/mongoid/errors/unsupported_isolation_level.rb +22 -0
- data/lib/mongoid/errors/unsupported_javascript.rb +1 -4
- data/lib/mongoid/errors/validations.rb +3 -5
- data/lib/mongoid/errors.rb +72 -72
- data/lib/mongoid/evolvable.rb +0 -3
- data/lib/mongoid/extensions/array.rb +5 -7
- data/lib/mongoid/extensions/big_decimal.rb +6 -7
- data/lib/mongoid/extensions/binary.rb +3 -6
- data/lib/mongoid/extensions/boolean.rb +4 -7
- data/lib/mongoid/extensions/bson_document.rb +28 -0
- data/lib/mongoid/extensions/date.rb +10 -14
- data/lib/mongoid/extensions/date_time.rb +2 -6
- data/lib/mongoid/extensions/decimal128.rb +1 -5
- data/lib/mongoid/extensions/false_class.rb +3 -5
- data/lib/mongoid/extensions/float.rb +5 -10
- data/lib/mongoid/extensions/hash.rb +5 -10
- data/lib/mongoid/extensions/integer.rb +5 -10
- data/lib/mongoid/extensions/module.rb +1 -4
- data/lib/mongoid/extensions/nil_class.rb +0 -1
- data/lib/mongoid/extensions/object.rb +9 -14
- data/lib/mongoid/extensions/object_id.rb +2 -6
- data/lib/mongoid/extensions/range.rb +14 -15
- data/lib/mongoid/extensions/raw_value.rb +0 -3
- data/lib/mongoid/extensions/regexp.rb +3 -6
- data/lib/mongoid/extensions/set.rb +3 -4
- data/lib/mongoid/extensions/string.rb +8 -12
- data/lib/mongoid/extensions/symbol.rb +3 -7
- data/lib/mongoid/extensions/time.rb +24 -26
- data/lib/mongoid/extensions/time_with_zone.rb +4 -7
- data/lib/mongoid/extensions/true_class.rb +3 -5
- data/lib/mongoid/extensions.rb +26 -26
- data/lib/mongoid/factory.rb +5 -9
- data/lib/mongoid/fields/encrypted.rb +0 -1
- data/lib/mongoid/fields/foreign_key.rb +9 -10
- data/lib/mongoid/fields/localized.rb +12 -12
- data/lib/mongoid/fields/standard.rb +5 -7
- data/lib/mongoid/fields/validators/macro.rb +23 -34
- data/lib/mongoid/fields/validators.rb +1 -2
- data/lib/mongoid/fields.rb +151 -58
- data/lib/mongoid/findable.rb +82 -53
- data/lib/mongoid/indexable/specification.rb +20 -6
- data/lib/mongoid/indexable/validators/options.rb +33 -40
- data/lib/mongoid/indexable.rb +26 -25
- data/lib/mongoid/inspectable.rb +4 -7
- data/lib/mongoid/interceptable.rb +41 -40
- data/lib/mongoid/loadable.rb +17 -18
- data/lib/mongoid/loggable.rb +4 -8
- data/lib/mongoid/matchable.rb +0 -2
- data/lib/mongoid/matcher/all.rb +2 -5
- data/lib/mongoid/matcher/and.rb +0 -3
- data/lib/mongoid/matcher/bits.rb +13 -8
- data/lib/mongoid/matcher/bits_all_clear.rb +1 -3
- data/lib/mongoid/matcher/bits_all_set.rb +1 -3
- data/lib/mongoid/matcher/bits_any_clear.rb +1 -3
- data/lib/mongoid/matcher/bits_any_set.rb +1 -3
- data/lib/mongoid/matcher/elem_match.rb +13 -15
- data/lib/mongoid/matcher/elem_match_expression.rb +0 -3
- data/lib/mongoid/matcher/eq.rb +0 -3
- data/lib/mongoid/matcher/eq_impl.rb +12 -17
- data/lib/mongoid/matcher/eq_impl_with_regexp.rb +4 -7
- data/lib/mongoid/matcher/exists.rb +1 -4
- data/lib/mongoid/matcher/expression.rb +5 -10
- data/lib/mongoid/matcher/expression_operator.rb +1 -3
- data/lib/mongoid/matcher/field_expression.rb +10 -13
- data/lib/mongoid/matcher/field_operator.rb +4 -6
- data/lib/mongoid/matcher/gt.rb +0 -3
- data/lib/mongoid/matcher/gte.rb +0 -3
- data/lib/mongoid/matcher/in.rb +9 -12
- data/lib/mongoid/matcher/lt.rb +0 -3
- data/lib/mongoid/matcher/lte.rb +0 -3
- data/lib/mongoid/matcher/mod.rb +4 -8
- data/lib/mongoid/matcher/ne.rb +0 -3
- data/lib/mongoid/matcher/nin.rb +0 -3
- data/lib/mongoid/matcher/nor.rb +1 -6
- data/lib/mongoid/matcher/not.rb +0 -3
- data/lib/mongoid/matcher/or.rb +0 -3
- data/lib/mongoid/matcher/regex.rb +11 -14
- data/lib/mongoid/matcher/size.rb +2 -5
- data/lib/mongoid/matcher/type.rb +32 -37
- data/lib/mongoid/matcher.rb +7 -15
- data/lib/mongoid/model_resolver.rb +1 -0
- data/lib/mongoid/persistable/creatable.rb +23 -7
- data/lib/mongoid/persistable/deletable.rb +6 -7
- data/lib/mongoid/persistable/destroyable.rb +2 -6
- data/lib/mongoid/persistable/incrementable.rb +1 -3
- data/lib/mongoid/persistable/logical.rb +3 -5
- data/lib/mongoid/persistable/maxable.rb +2 -4
- data/lib/mongoid/persistable/minable.rb +2 -4
- data/lib/mongoid/persistable/multipliable.rb +1 -3
- data/lib/mongoid/persistable/poppable.rb +2 -4
- data/lib/mongoid/persistable/pullable.rb +3 -5
- data/lib/mongoid/persistable/pushable.rb +5 -7
- data/lib/mongoid/persistable/renamable.rb +1 -3
- data/lib/mongoid/persistable/savable.rb +0 -3
- data/lib/mongoid/persistable/settable.rb +4 -13
- data/lib/mongoid/persistable/unsettable.rb +1 -3
- data/lib/mongoid/persistable/updatable.rb +16 -24
- data/lib/mongoid/persistable/upsertable.rb +8 -10
- data/lib/mongoid/persistable.rb +28 -27
- data/lib/mongoid/persistence_context.rb +34 -41
- data/lib/mongoid/pluckable.rb +0 -2
- data/lib/mongoid/positional.rb +5 -11
- data/lib/mongoid/railtie.rb +16 -22
- data/lib/mongoid/railties/console_sandbox.rb +6 -8
- data/lib/mongoid/railties/controller_runtime.rb +7 -11
- data/lib/mongoid/railties/database.rake +42 -44
- data/lib/mongoid/scopable.rb +23 -31
- data/lib/mongoid/search_indexable.rb +330 -0
- data/lib/mongoid/selectable.rb +1 -3
- data/lib/mongoid/serializable.rb +6 -8
- data/lib/mongoid/shardable.rb +8 -17
- data/lib/mongoid/stateful.rb +5 -10
- data/lib/mongoid/stringified_symbol.rb +5 -9
- data/lib/mongoid/tasks/database.rake +31 -32
- data/lib/mongoid/tasks/database.rb +28 -30
- data/lib/mongoid/tasks/encryption.rb +10 -15
- data/lib/mongoid/threaded/lifecycle.rb +6 -9
- data/lib/mongoid/threaded.rb +132 -32
- data/lib/mongoid/timestamps/created/short.rb +2 -3
- data/lib/mongoid/timestamps/created.rb +1 -2
- data/lib/mongoid/timestamps/short.rb +0 -1
- data/lib/mongoid/timestamps/timeless.rb +8 -13
- data/lib/mongoid/timestamps/updated/short.rb +2 -3
- data/lib/mongoid/timestamps/updated.rb +2 -5
- data/lib/mongoid/timestamps.rb +4 -6
- data/lib/mongoid/touchable.rb +19 -11
- data/lib/mongoid/traversable.rb +3 -2
- data/lib/mongoid/validatable/associated.rb +1 -5
- data/lib/mongoid/validatable/format.rb +0 -2
- data/lib/mongoid/validatable/length.rb +0 -2
- data/lib/mongoid/validatable/localizable.rb +0 -3
- data/lib/mongoid/validatable/macros.rb +0 -2
- data/lib/mongoid/validatable/numericality.rb +24 -3
- data/lib/mongoid/validatable/presence.rb +8 -10
- data/lib/mongoid/validatable/queryable.rb +0 -3
- data/lib/mongoid/validatable/uniqueness.rb +12 -14
- data/lib/mongoid/validatable.rb +15 -20
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid/warnings.rb +10 -11
- data/lib/mongoid.rb +30 -34
- data/lib/rails/generators/mongoid/config/config_generator.rb +2 -4
- data/lib/rails/generators/mongoid/config/templates/mongoid.rb +4 -5
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +2 -2
- data/lib/rails/generators/mongoid/model/model_generator.rb +5 -8
- data/lib/rails/generators/mongoid_generator.rb +6 -10
- data/lib/rails/mongoid.rb +1 -3
- data/spec/integration/active_job_spec.rb +1 -2
- data/spec/integration/app_spec.rb +142 -178
- data/spec/integration/associations/belongs_to_spec.rb +30 -28
- data/spec/integration/associations/embedded_dirty_spec.rb +0 -1
- data/spec/integration/associations/embedded_spec.rb +41 -43
- data/spec/integration/associations/embeds_many_spec.rb +46 -29
- data/spec/integration/associations/embeds_one_spec.rb +2 -1
- data/spec/integration/associations/foreign_key_spec.rb +10 -11
- data/spec/integration/associations/foreign_key_spec_models.rb +8 -9
- data/spec/integration/associations/has_and_belongs_to_many_spec.rb +16 -13
- data/spec/integration/associations/has_many_spec.rb +17 -18
- data/spec/integration/associations/has_one_spec.rb +42 -45
- data/spec/integration/associations/nested_attributes_assignment_spec.rb +36 -39
- data/spec/integration/associations/reverse_population_spec.rb +4 -5
- data/spec/integration/associations/reverse_population_spec_models.rb +0 -1
- data/spec/integration/associations/scope_option_spec.rb +18 -20
- data/spec/integration/atomic/modifiers_spec.rb +72 -52
- data/spec/integration/bson_regexp_raw_spec.rb +2 -3
- data/spec/integration/caching_spec.rb +68 -0
- data/spec/integration/callbacks_models.rb +11 -9
- data/spec/integration/callbacks_spec.rb +78 -80
- data/spec/integration/contextual/empty_spec.rb +19 -20
- data/spec/integration/criteria/alias_query_spec.rb +12 -19
- data/spec/integration/criteria/date_field_spec.rb +1 -2
- data/spec/integration/criteria/default_scope_spec.rb +23 -18
- data/spec/integration/criteria/logical_spec.rb +18 -19
- data/spec/integration/criteria/range_spec.rb +77 -86
- data/spec/integration/criteria/raw_value_spec.rb +122 -109
- data/spec/integration/criteria/time_with_zone_spec.rb +33 -24
- data/spec/integration/discriminator_key_spec.rb +85 -85
- data/spec/integration/discriminator_value_spec.rb +70 -73
- data/spec/integration/document_spec.rb +9 -10
- data/spec/integration/dots_and_dollars_spec.rb +104 -119
- data/spec/integration/encryption_spec.rb +8 -11
- data/spec/integration/i18n_fallbacks_spec.rb +7 -8
- data/spec/integration/isolation_state_spec.rb +241 -0
- data/spec/integration/matcher_examples_spec.rb +145 -168
- data/spec/integration/matcher_operator_data/in.yml +6 -6
- data/spec/integration/matcher_operator_spec.rb +16 -26
- data/spec/integration/matcher_spec.rb +31 -32
- data/spec/integration/persistence/collection_options_spec.rb +0 -2
- data/spec/integration/persistence/range_field_spec.rb +24 -2
- data/spec/integration/server_query_spec.rb +43 -37
- data/spec/integration/shardable_spec.rb +10 -11
- data/spec/integration/stringified_symbol_field_spec.rb +28 -43
- data/spec/lite_spec_helper.rb +11 -12
- data/spec/mongoid/association/accessors_spec.rb +197 -285
- data/spec/mongoid/association/auto_save_spec.rb +62 -93
- data/spec/mongoid/association/builders_spec.rb +121 -74
- data/spec/mongoid/association/constrainable_spec.rb +9 -22
- data/spec/mongoid/association/counter_cache_spec.rb +71 -104
- data/spec/mongoid/association/depending_spec.rb +166 -208
- data/spec/mongoid/association/eager_spec.rb +416 -80
- data/spec/mongoid/association/embedded/cyclic_spec.rb +36 -48
- data/spec/mongoid/association/embedded/dirty_spec.rb +15 -20
- data/spec/mongoid/association/embedded/embedded_in/binding_spec.rb +36 -54
- data/spec/mongoid/association/embedded/embedded_in/buildable_spec.rb +8 -15
- data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +135 -175
- data/spec/mongoid/association/embedded/embedded_in_spec.rb +25 -127
- data/spec/mongoid/association/embedded/embeds_many/binding_spec.rb +9 -14
- data/spec/mongoid/association/embedded/embeds_many/buildable_spec.rb +38 -51
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +1151 -1340
- data/spec/mongoid/association/embedded/embeds_many_models.rb +17 -17
- data/spec/mongoid/association/embedded/embeds_many_query_spec.rb +11 -11
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +25 -138
- data/spec/mongoid/association/embedded/embeds_one/binding_spec.rb +15 -23
- data/spec/mongoid/association/embedded/embeds_one/buildable_spec.rb +18 -26
- data/spec/mongoid/association/embedded/embeds_one/proxy_spec.rb +204 -273
- data/spec/mongoid/association/embedded/embeds_one_dnl_models.rb +0 -1
- data/spec/mongoid/association/embedded/embeds_one_models.rb +0 -1
- data/spec/mongoid/association/embedded/embeds_one_query_spec.rb +5 -6
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +28 -143
- data/spec/mongoid/association/macros_spec.rb +213 -300
- data/spec/mongoid/association/nested/many_spec.rb +51 -73
- data/spec/mongoid/association/nested/one_spec.rb +56 -80
- data/spec/mongoid/association/options_spec.rb +187 -310
- data/spec/mongoid/association/polymorphic_spec.rb +35 -53
- data/spec/mongoid/association/referenced/belongs_to/binding_spec.rb +55 -76
- data/spec/mongoid/association/referenced/belongs_to/buildable_spec.rb +36 -41
- data/spec/mongoid/association/referenced/belongs_to/eager_spec.rb +81 -101
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +258 -345
- data/spec/mongoid/association/referenced/belongs_to_models.rb +4 -3
- data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +3 -4
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +91 -294
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +42 -56
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb +41 -32
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/eager_spec.rb +36 -42
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_persistence_spec.rb +8 -9
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +771 -975
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb +9 -9
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_query_spec.rb +5 -6
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb +59 -177
- data/spec/mongoid/association/referenced/has_many/binding_spec.rb +29 -43
- data/spec/mongoid/association/referenced/has_many/buildable_spec.rb +53 -53
- data/spec/mongoid/association/referenced/has_many/eager_spec.rb +104 -67
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +431 -675
- data/spec/mongoid/association/referenced/has_many/proxy_query_spec.rb +1 -2
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +173 -11
- data/spec/mongoid/association/referenced/has_many_models.rb +1 -2
- data/spec/mongoid/association/referenced/has_many_query_spec.rb +3 -4
- data/spec/mongoid/association/referenced/has_many_spec.rb +44 -188
- data/spec/mongoid/association/referenced/has_one/binding_spec.rb +26 -38
- data/spec/mongoid/association/referenced/has_one/buildable_spec.rb +28 -29
- data/spec/mongoid/association/referenced/has_one/eager_spec.rb +29 -42
- data/spec/mongoid/association/referenced/has_one/proxy_spec.rb +270 -332
- data/spec/mongoid/association/referenced/has_one_models.rb +1 -2
- data/spec/mongoid/association/referenced/has_one_query_spec.rb +3 -4
- data/spec/mongoid/association/referenced/has_one_spec.rb +40 -188
- data/spec/mongoid/association/reflections_spec.rb +14 -24
- data/spec/mongoid/association/syncable_spec.rb +102 -125
- data/spec/mongoid/association_spec.rb +47 -70
- data/spec/mongoid/atomic/modifiers_spec.rb +184 -197
- data/spec/mongoid/atomic/paths/embedded/many_spec.rb +39 -52
- data/spec/mongoid/atomic/paths/embedded/one_spec.rb +35 -49
- data/spec/mongoid/atomic/paths/root_spec.rb +9 -15
- data/spec/mongoid/atomic/paths_spec.rb +81 -117
- data/spec/mongoid/atomic_spec.rb +156 -171
- data/spec/mongoid/attributes/dynamic_spec.rb +5 -6
- data/spec/mongoid/attributes/nested_spec.rb +1219 -1692
- data/spec/mongoid/attributes/nested_spec_models.rb +8 -9
- data/spec/mongoid/attributes/projector_spec.rb +2 -6
- data/spec/mongoid/attributes/readonly_spec.rb +73 -97
- data/spec/mongoid/attributes_spec.rb +669 -826
- data/spec/mongoid/cacheable_spec.rb +74 -44
- data/spec/mongoid/changeable_spec.rb +591 -733
- data/spec/mongoid/clients/factory_spec.rb +122 -154
- data/spec/mongoid/clients/options_spec.rb +40 -59
- data/spec/mongoid/clients/sessions_spec.rb +25 -44
- data/spec/mongoid/clients/transactions_spec.rb +33 -50
- data/spec/mongoid/clients/transactions_spec_models.rb +3 -4
- data/spec/mongoid/clients_spec.rb +265 -355
- data/spec/mongoid/collection_configurable_spec.rb +9 -12
- data/spec/mongoid/composable_spec.rb +2 -9
- data/spec/mongoid/config/defaults_spec.rb +24 -31
- data/spec/mongoid/config/encryption_spec.rb +54 -57
- data/spec/mongoid/config/environment_spec.rb +30 -40
- data/spec/mongoid/config/introspection_spec.rb +42 -37
- data/spec/mongoid/config/options_spec.rb +14 -21
- data/spec/mongoid/config_spec.rb +145 -195
- data/spec/mongoid/contextual/aggregable/memory_spec.rb +98 -135
- data/spec/mongoid/contextual/aggregable/memory_table_spec.rb +4 -7
- data/spec/mongoid/contextual/aggregable/mongo_spec.rb +149 -187
- data/spec/mongoid/contextual/aggregable/none_spec.rb +14 -16
- data/spec/mongoid/contextual/atomic_spec.rb +223 -271
- data/spec/mongoid/contextual/map_reduce_spec.rb +110 -138
- data/spec/mongoid/contextual/memory_spec.rb +706 -854
- data/spec/mongoid/contextual/mongo/documents_loader_spec.rb +12 -13
- data/spec/mongoid/contextual/mongo_spec.rb +1008 -1213
- data/spec/mongoid/contextual/none_spec.rb +54 -59
- data/spec/mongoid/contextual/short_circuit_spec.rb +139 -0
- data/spec/mongoid/copyable_spec.rb +254 -300
- data/spec/mongoid/copyable_spec_models.rb +0 -1
- data/spec/mongoid/criteria/findable_spec.rb +322 -387
- data/spec/mongoid/criteria/includable_spec.rb +421 -372
- data/spec/mongoid/criteria/includable_spec_models.rb +16 -7
- data/spec/mongoid/criteria/inspectable_spec.rb +11 -14
- data/spec/mongoid/criteria/marshalable_spec.rb +11 -14
- data/spec/mongoid/criteria/modifiable_spec.rb +366 -512
- data/spec/mongoid/criteria/options_spec.rb +2 -7
- data/spec/mongoid/criteria/queryable/aggregable_spec.rb +112 -141
- data/spec/mongoid/criteria/queryable/expandable_spec.rb +8 -11
- data/spec/mongoid/criteria/queryable/extensions/array_spec.rb +127 -184
- data/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb +123 -60
- data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +84 -117
- data/spec/mongoid/criteria/queryable/extensions/date_spec.rb +44 -65
- data/spec/mongoid/criteria/queryable/extensions/date_time_spec.rb +86 -108
- data/spec/mongoid/criteria/queryable/extensions/float_spec.rb +94 -33
- data/spec/mongoid/criteria/queryable/extensions/hash_spec.rb +103 -138
- data/spec/mongoid/criteria/queryable/extensions/integer_spec.rb +95 -34
- data/spec/mongoid/criteria/queryable/extensions/nil_class_spec.rb +25 -38
- data/spec/mongoid/criteria/queryable/extensions/numeric_spec.rb +26 -28
- data/spec/mongoid/criteria/queryable/extensions/object_spec.rb +32 -54
- data/spec/mongoid/criteria/queryable/extensions/range_spec.rb +136 -130
- data/spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb +16 -24
- data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +15 -24
- data/spec/mongoid/criteria/queryable/extensions/set_spec.rb +12 -19
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +46 -63
- data/spec/mongoid/criteria/queryable/extensions/symbol_spec.rb +28 -42
- data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +73 -96
- data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +71 -92
- data/spec/mongoid/criteria/queryable/key_spec.rb +32 -36
- data/spec/mongoid/criteria/queryable/mergeable_spec.rb +44 -49
- data/spec/mongoid/criteria/queryable/optional_spec.rb +373 -486
- data/spec/mongoid/criteria/queryable/options_spec.rb +172 -123
- data/spec/mongoid/criteria/queryable/pipeline_spec.rb +65 -87
- data/spec/mongoid/criteria/queryable/queryable_spec.rb +41 -53
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +576 -680
- data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +7 -11
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +807 -998
- data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +154 -191
- data/spec/mongoid/criteria/queryable/selector_spec.rb +294 -390
- data/spec/mongoid/criteria/queryable/smash_spec.rb +6 -11
- data/spec/mongoid/criteria/queryable/storable_spec.rb +54 -81
- data/spec/mongoid/criteria/queryable_mql_spec.rb +92 -0
- data/spec/mongoid/criteria/scopable_spec.rb +102 -138
- data/spec/mongoid/criteria/translator_spec.rb +59 -60
- data/spec/mongoid/criteria_projection_spec.rb +81 -99
- data/spec/mongoid/criteria_spec.rb +935 -950
- data/spec/mongoid/document_fields_spec.rb +28 -30
- data/spec/mongoid/document_persistence_context_spec.rb +13 -15
- data/spec/mongoid/document_query_spec.rb +9 -12
- data/spec/mongoid/document_spec.rb +317 -409
- data/spec/mongoid/equality_spec.rb +69 -102
- data/spec/mongoid/errors/ambiguous_relationship_spec.rb +8 -11
- data/spec/mongoid/errors/attribute_not_loaded_spec.rb +7 -10
- data/spec/mongoid/errors/callback_spec.rb +8 -11
- data/spec/mongoid/errors/delete_restriction_spec.rb +5 -8
- data/spec/mongoid/errors/document_not_destroyed_spec.rb +7 -10
- data/spec/mongoid/errors/document_not_found_spec.rb +51 -61
- data/spec/mongoid/errors/invalid_collection_spec.rb +9 -13
- data/spec/mongoid/errors/invalid_config_file_spec.rb +8 -11
- data/spec/mongoid/errors/invalid_config_option_spec.rb +8 -11
- data/spec/mongoid/errors/invalid_field_option_spec.rb +7 -10
- data/spec/mongoid/errors/invalid_field_spec.rb +10 -11
- data/spec/mongoid/errors/invalid_field_type_spec.rb +9 -12
- data/spec/mongoid/errors/invalid_find_spec.rb +8 -11
- data/spec/mongoid/errors/invalid_includes_spec.rb +9 -13
- data/spec/mongoid/errors/invalid_index_spec.rb +8 -11
- data/spec/mongoid/errors/invalid_options_spec.rb +8 -11
- data/spec/mongoid/errors/invalid_path_spec.rb +7 -10
- data/spec/mongoid/errors/invalid_relation_spec.rb +15 -16
- data/spec/mongoid/errors/invalid_scope_spec.rb +8 -11
- data/spec/mongoid/errors/invalid_set_polymorphic_relation_spec.rb +3 -6
- data/spec/mongoid/errors/invalid_storage_options_spec.rb +8 -11
- data/spec/mongoid/errors/invalid_time_spec.rb +8 -11
- data/spec/mongoid/errors/inverse_not_found_spec.rb +9 -12
- data/spec/mongoid/errors/mixed_client_configuration_spec.rb +9 -12
- data/spec/mongoid/errors/mixed_relations_spec.rb +8 -11
- data/spec/mongoid/errors/mongoid_error_spec.rb +21 -24
- data/spec/mongoid/errors/nested_attributes_metadata_not_found_spec.rb +6 -9
- data/spec/mongoid/errors/no_client_config_spec.rb +7 -10
- data/spec/mongoid/errors/no_client_database_spec.rb +9 -12
- data/spec/mongoid/errors/no_client_hosts_spec.rb +9 -12
- data/spec/mongoid/errors/no_clients_config_spec.rb +7 -10
- data/spec/mongoid/errors/no_environment_spec.rb +8 -11
- data/spec/mongoid/errors/no_map_reduce_output_spec.rb +8 -11
- data/spec/mongoid/errors/no_metadata_spec.rb +7 -10
- data/spec/mongoid/errors/no_parent_spec.rb +7 -10
- data/spec/mongoid/errors/readonly_attribute_spec.rb +7 -10
- data/spec/mongoid/errors/readonly_document_spec.rb +6 -9
- data/spec/mongoid/errors/scope_overwrite_spec.rb +9 -12
- data/spec/mongoid/errors/too_many_nested_attribute_records_spec.rb +9 -12
- data/spec/mongoid/errors/unknown_attribute_spec.rb +5 -8
- data/spec/mongoid/errors/unsaved_document_spec.rb +8 -11
- data/spec/mongoid/errors/unsupported_javascript_spec.rb +9 -12
- data/spec/mongoid/errors/validations_spec.rb +11 -14
- data/spec/mongoid/extensions/array_spec.rb +70 -92
- data/spec/mongoid/extensions/big_decimal_spec.rb +233 -313
- data/spec/mongoid/extensions/binary_spec.rb +21 -32
- data/spec/mongoid/extensions/boolean_spec.rb +52 -75
- data/spec/mongoid/extensions/date_class_mongoize_spec.rb +43 -54
- data/spec/mongoid/extensions/date_spec.rb +26 -38
- data/spec/mongoid/extensions/date_time_spec.rb +22 -32
- data/spec/mongoid/extensions/decimal128_spec.rb +12 -18
- data/spec/mongoid/extensions/false_class_spec.rb +10 -17
- data/spec/mongoid/extensions/float_spec.rb +40 -61
- data/spec/mongoid/extensions/hash_spec.rb +46 -64
- data/spec/mongoid/extensions/integer_spec.rb +40 -61
- data/spec/mongoid/extensions/module_spec.rb +13 -18
- data/spec/mongoid/extensions/nil_class_spec.rb +2 -5
- data/spec/mongoid/extensions/object_id_spec.rb +159 -247
- data/spec/mongoid/extensions/object_spec.rb +31 -47
- data/spec/mongoid/extensions/range_spec.rb +112 -115
- data/spec/mongoid/extensions/raw_value_spec.rb +10 -12
- data/spec/mongoid/extensions/regexp_spec.rb +23 -36
- data/spec/mongoid/extensions/set_spec.rb +38 -49
- data/spec/mongoid/extensions/string_spec.rb +118 -167
- data/spec/mongoid/extensions/stringified_symbol_spec.rb +29 -43
- data/spec/mongoid/extensions/symbol_spec.rb +12 -20
- data/spec/mongoid/extensions/time_spec.rb +160 -202
- data/spec/mongoid/extensions/time_with_zone_spec.rb +79 -105
- data/spec/mongoid/extensions/true_class_spec.rb +10 -17
- data/spec/mongoid/factory_spec.rb +125 -148
- data/spec/mongoid/fields/foreign_key_spec.rb +124 -169
- data/spec/mongoid/fields/localized_spec.rb +140 -185
- data/spec/mongoid/fields/standard_spec.rb +43 -59
- data/spec/mongoid/fields_spec.rb +751 -620
- data/spec/mongoid/findable_spec.rb +260 -228
- data/spec/mongoid/indexable/specification_spec.rb +42 -58
- data/spec/mongoid/indexable_spec.rb +260 -264
- data/spec/mongoid/inspectable_spec.rb +45 -55
- data/spec/mongoid/interceptable_spec.rb +784 -922
- data/spec/mongoid/interceptable_spec_models.rb +35 -35
- data/spec/mongoid/loading_spec.rb +47 -43
- data/spec/mongoid/loggable_spec.rb +3 -6
- data/spec/mongoid/matcher/extract_attribute_spec.rb +2 -6
- data/spec/mongoid/mongoizable_spec.rb +81 -90
- data/spec/mongoid/monkey_patches_spec.rb +4 -0
- data/spec/mongoid/persistable/creatable_spec.rb +181 -220
- data/spec/mongoid/persistable/deletable_spec.rb +139 -179
- data/spec/mongoid/persistable/destroyable_spec.rb +135 -164
- data/spec/mongoid/persistable/incrementable_spec.rb +65 -84
- data/spec/mongoid/persistable/logical_spec.rb +48 -61
- data/spec/mongoid/persistable/maxable_spec.rb +45 -44
- data/spec/mongoid/persistable/minable_spec.rb +45 -44
- data/spec/mongoid/persistable/multipliable_spec.rb +54 -69
- data/spec/mongoid/persistable/poppable_spec.rb +47 -60
- data/spec/mongoid/persistable/pullable_spec.rb +79 -103
- data/spec/mongoid/persistable/pushable_spec.rb +106 -131
- data/spec/mongoid/persistable/renamable_spec.rb +52 -65
- data/spec/mongoid/persistable/savable_spec.rb +152 -189
- data/spec/mongoid/persistable/settable_spec.rb +121 -145
- data/spec/mongoid/persistable/unsettable_spec.rb +56 -73
- data/spec/mongoid/persistable/updatable_spec.rb +185 -232
- data/spec/mongoid/persistable/upsertable_spec.rb +66 -77
- data/spec/mongoid/persistable_spec.rb +132 -139
- data/spec/mongoid/persistence_context_spec.rb +31 -89
- data/spec/mongoid/positional_spec.rb +67 -79
- data/spec/mongoid/railties/bson_object_id_serializer_spec.rb +0 -3
- data/spec/mongoid/railties/console_sandbox_spec.rb +0 -1
- data/spec/mongoid/relations/proxy_spec.rb +0 -1
- data/spec/mongoid/reloadable_spec.rb +250 -145
- data/spec/mongoid/scopable_spec.rb +319 -398
- data/spec/mongoid/search_indexable_spec.rb +446 -41
- data/spec/mongoid/selectable_spec.rb +36 -51
- data/spec/mongoid/serializable_spec.rb +269 -312
- data/spec/mongoid/shardable_models.rb +5 -5
- data/spec/mongoid/shardable_spec.rb +44 -46
- data/spec/mongoid/stateful_spec.rb +55 -75
- data/spec/mongoid/tasks/database_rake_spec.rb +138 -141
- data/spec/mongoid/tasks/database_spec.rb +80 -80
- data/spec/mongoid/tasks/encryption_spec.rb +22 -20
- data/spec/mongoid/threaded_spec.rb +57 -83
- data/spec/mongoid/timestamps/created/short_spec.rb +12 -16
- data/spec/mongoid/timestamps/created_spec.rb +16 -20
- data/spec/mongoid/timestamps/timeless_spec.rb +31 -43
- data/spec/mongoid/timestamps/updated/short_spec.rb +21 -28
- data/spec/mongoid/timestamps/updated_spec.rb +18 -25
- data/spec/mongoid/timestamps_spec.rb +171 -188
- data/spec/mongoid/timestamps_spec_models.rb +12 -13
- data/spec/mongoid/touchable_spec.rb +330 -294
- data/spec/mongoid/touchable_spec_models.rb +35 -37
- data/spec/mongoid/traversable_spec.rb +435 -471
- data/spec/mongoid/validatable/associated_spec.rb +42 -60
- data/spec/mongoid/validatable/format_spec.rb +24 -34
- data/spec/mongoid/validatable/length_spec.rb +62 -86
- data/spec/mongoid/validatable/numericality_spec.rb +114 -23
- data/spec/mongoid/validatable/presence_spec.rb +149 -203
- data/spec/mongoid/validatable/uniqueness_spec.rb +632 -830
- data/spec/mongoid/validatable_spec.rb +71 -103
- data/spec/mongoid/warnings_spec.rb +5 -9
- data/spec/mongoid_spec.rb +25 -41
- data/spec/rails/controller_extension/controller_runtime_spec.rb +45 -49
- data/spec/rails/mongoid_spec.rb +15 -15
- data/spec/shared/lib/mrss/cluster_config.rb +5 -40
- data/spec/shared/lib/mrss/constraints.rb +7 -46
- data/spec/shared/lib/mrss/docker_runner.rb +10 -21
- data/spec/shared/lib/mrss/eg_config_utils.rb +0 -31
- data/spec/shared/lib/mrss/release/candidate.rb +18 -12
- data/spec/shared/lib/mrss/server_version_registry.rb +1 -5
- data/spec/shared/share/Dockerfile.erb +6 -8
- data/spec/shared/shlib/server.sh +0 -50
- data/spec/shared/shlib/set_env.sh +4 -10
- data/spec/spec_helper.rb +54 -31
- data/spec/support/authorization.rb +0 -1
- data/spec/support/client_registry.rb +1 -2
- data/spec/support/constraints.rb +8 -25
- data/spec/support/crypt/models.rb +7 -8
- data/spec/support/crypt.rb +6 -9
- data/spec/support/expectations.rb +21 -7
- data/spec/support/feature_sandbox.rb +1 -4
- data/spec/support/helpers.rb +0 -1
- data/spec/support/immutable_ids.rb +20 -21
- data/spec/support/macros.rb +1 -3
- data/spec/support/models/account.rb +4 -5
- data/spec/support/models/acolyte.rb +5 -5
- data/spec/support/models/actor.rb +3 -3
- data/spec/support/models/actress.rb +0 -1
- data/spec/support/models/address.rb +11 -11
- data/spec/support/models/address_component.rb +1 -1
- data/spec/support/models/address_number.rb +1 -1
- data/spec/support/models/agency.rb +1 -1
- data/spec/support/models/agent.rb +1 -1
- data/spec/support/models/album.rb +1 -2
- data/spec/support/models/alert.rb +1 -1
- data/spec/support/models/animal.rb +4 -5
- data/spec/support/models/answer.rb +1 -1
- data/spec/support/models/appointment.rb +2 -2
- data/spec/support/models/armrest.rb +0 -1
- data/spec/support/models/array_field.rb +0 -1
- data/spec/support/models/article.rb +0 -1
- data/spec/support/models/artist.rb +16 -12
- data/spec/support/models/artwork.rb +1 -1
- data/spec/support/models/audible_sound.rb +0 -1
- data/spec/support/models/audio.rb +2 -2
- data/spec/support/models/augmentation.rb +1 -2
- data/spec/support/models/author.rb +1 -1
- data/spec/support/models/baby.rb +1 -1
- data/spec/support/models/band.rb +0 -1
- data/spec/support/models/bar.rb +2 -2
- data/spec/support/models/basic.rb +0 -1
- data/spec/support/models/bed.rb +0 -1
- data/spec/support/models/big_palette.rb +0 -1
- data/spec/support/models/birthday.rb +3 -5
- data/spec/support/models/bolt.rb +0 -1
- data/spec/support/models/bomb.rb +1 -1
- data/spec/support/models/book.rb +1 -1
- data/spec/support/models/breed.rb +1 -1
- data/spec/support/models/browser.rb +1 -2
- data/spec/support/models/building.rb +0 -1
- data/spec/support/models/building_address.rb +1 -1
- data/spec/support/models/bus.rb +1 -1
- data/spec/support/models/business.rb +2 -2
- data/spec/support/models/callback_test.rb +1 -1
- data/spec/support/models/canvas.rb +5 -6
- data/spec/support/models/car.rb +0 -1
- data/spec/support/models/cat.rb +0 -2
- data/spec/support/models/catalog.rb +0 -1
- data/spec/support/models/category.rb +1 -1
- data/spec/support/models/child.rb +1 -1
- data/spec/support/models/child_doc.rb +5 -6
- data/spec/support/models/church.rb +1 -1
- data/spec/support/models/circle.rb +0 -1
- data/spec/support/models/circuit.rb +2 -2
- data/spec/support/models/circus.rb +0 -1
- data/spec/support/models/code.rb +2 -1
- data/spec/support/models/coding/pull_request.rb +0 -1
- data/spec/support/models/coding.rb +0 -1
- data/spec/support/models/comment.rb +0 -1
- data/spec/support/models/company.rb +0 -1
- data/spec/support/models/consumption_period.rb +0 -1
- data/spec/support/models/contextable_item.rb +1 -1
- data/spec/support/models/contractor.rb +1 -1
- data/spec/support/models/cookie.rb +0 -1
- data/spec/support/models/country_code.rb +2 -3
- data/spec/support/models/courier_job.rb +2 -2
- data/spec/support/models/cover.rb +0 -1
- data/spec/support/models/crate.rb +0 -1
- data/spec/support/models/customer.rb +0 -1
- data/spec/support/models/customer_address.rb +0 -1
- data/spec/support/models/deed.rb +1 -1
- data/spec/support/models/definition.rb +1 -1
- data/spec/support/models/delegating_patient.rb +0 -1
- data/spec/support/models/description.rb +0 -1
- data/spec/support/models/dictionary.rb +1 -1
- data/spec/support/models/division.rb +2 -2
- data/spec/support/models/doctor.rb +0 -1
- data/spec/support/models/dog.rb +2 -2
- data/spec/support/models/dokument.rb +1 -1
- data/spec/support/models/draft.rb +0 -1
- data/spec/support/models/dragon.rb +1 -1
- data/spec/support/models/driver.rb +2 -2
- data/spec/support/models/drug.rb +1 -1
- data/spec/support/models/dungeon.rb +1 -1
- data/spec/support/models/edit.rb +1 -1
- data/spec/support/models/email.rb +1 -1
- data/spec/support/models/employer.rb +1 -2
- data/spec/support/models/entry.rb +1 -1
- data/spec/support/models/eraser.rb +0 -1
- data/spec/support/models/even.rb +1 -1
- data/spec/support/models/event.rb +3 -4
- data/spec/support/models/exhibition.rb +1 -1
- data/spec/support/models/exhibitor.rb +1 -1
- data/spec/support/models/explosion.rb +1 -1
- data/spec/support/models/eye.rb +0 -1
- data/spec/support/models/eye_bowl.rb +2 -3
- data/spec/support/models/face.rb +2 -3
- data/spec/support/models/fanatic.rb +1 -1
- data/spec/support/models/favorite.rb +1 -1
- data/spec/support/models/filesystem.rb +1 -1
- data/spec/support/models/fire_hydrant.rb +1 -1
- data/spec/support/models/firefox.rb +0 -1
- data/spec/support/models/fish.rb +0 -1
- data/spec/support/models/folder.rb +0 -2
- data/spec/support/models/folder_item.rb +1 -3
- data/spec/support/models/fruits.rb +9 -5
- data/spec/support/models/game.rb +3 -4
- data/spec/support/models/ghost.rb +0 -1
- data/spec/support/models/guitar.rb +0 -1
- data/spec/support/models/hole.rb +0 -1
- data/spec/support/models/home.rb +1 -1
- data/spec/support/models/house.rb +2 -2
- data/spec/support/models/html_writer.rb +0 -1
- data/spec/support/models/id_key.rb +3 -3
- data/spec/support/models/idnodef.rb +0 -1
- data/spec/support/models/image.rb +0 -1
- data/spec/support/models/implant.rb +1 -2
- data/spec/support/models/instrument.rb +2 -3
- data/spec/support/models/item.rb +2 -2
- data/spec/support/models/jar.rb +1 -2
- data/spec/support/models/kaleidoscope.rb +1 -1
- data/spec/support/models/kangaroo.rb +1 -1
- data/spec/support/models/label.rb +2 -2
- data/spec/support/models/language.rb +1 -1
- data/spec/support/models/lat_lng.rb +0 -1
- data/spec/support/models/league.rb +1 -1
- data/spec/support/models/learner.rb +0 -1
- data/spec/support/models/line_item.rb +1 -1
- data/spec/support/models/location.rb +1 -1
- data/spec/support/models/login.rb +1 -2
- data/spec/support/models/manufacturer.rb +0 -1
- data/spec/support/models/meat.rb +1 -1
- data/spec/support/models/membership.rb +1 -1
- data/spec/support/models/message.rb +1 -2
- data/spec/support/models/minim.rb +0 -1
- data/spec/support/models/mixed_drink.rb +1 -1
- data/spec/support/models/modifier_models.rb +25 -0
- data/spec/support/models/mop.rb +0 -1
- data/spec/support/models/movie.rb +1 -1
- data/spec/support/models/my_hash.rb +1 -2
- data/spec/support/models/name.rb +4 -5
- data/spec/support/models/name_only.rb +0 -1
- data/spec/support/models/node.rb +1 -1
- data/spec/support/models/note.rb +3 -3
- data/spec/support/models/nut.rb +0 -1
- data/spec/support/models/odd.rb +1 -1
- data/spec/support/models/order.rb +1 -1
- data/spec/support/models/ordered_post.rb +1 -1
- data/spec/support/models/ordered_preference.rb +1 -1
- data/spec/support/models/oscar.rb +1 -1
- data/spec/support/models/other_owner_object.rb +0 -1
- data/spec/support/models/override.rb +3 -11
- data/spec/support/models/ownable.rb +1 -1
- data/spec/support/models/owner.rb +1 -1
- data/spec/support/models/pack.rb +0 -1
- data/spec/support/models/page.rb +3 -3
- data/spec/support/models/page_question.rb +1 -1
- data/spec/support/models/palette.rb +2 -2
- data/spec/support/models/parent.rb +2 -2
- data/spec/support/models/parent_doc.rb +1 -1
- data/spec/support/models/passport.rb +0 -1
- data/spec/support/models/patient.rb +2 -2
- data/spec/support/models/pdf_writer.rb +0 -1
- data/spec/support/models/pencil.rb +0 -1
- data/spec/support/models/person.rb +32 -28
- data/spec/support/models/pet.rb +1 -1
- data/spec/support/models/pet_owner.rb +1 -1
- data/spec/support/models/phone.rb +1 -2
- data/spec/support/models/piano.rb +0 -1
- data/spec/support/models/pizza.rb +1 -1
- data/spec/support/models/player.rb +5 -5
- data/spec/support/models/post.rb +12 -12
- data/spec/support/models/post_genre.rb +1 -1
- data/spec/support/models/powerup.rb +1 -2
- data/spec/support/models/preference.rb +2 -2
- data/spec/support/models/princess.rb +1 -1
- data/spec/support/models/product.rb +3 -3
- data/spec/support/models/profile.rb +2 -1
- data/spec/support/models/pronunciation.rb +1 -1
- data/spec/support/models/pub.rb +2 -2
- data/spec/support/models/publication/encyclopedia.rb +0 -1
- data/spec/support/models/publication/review.rb +0 -1
- data/spec/support/models/publication.rb +0 -1
- data/spec/support/models/purchase.rb +1 -1
- data/spec/support/models/purchased_item.rb +1 -1
- data/spec/support/models/question.rb +2 -2
- data/spec/support/models/quiz.rb +1 -1
- data/spec/support/models/rating.rb +1 -1
- data/spec/support/models/record.rb +2 -3
- data/spec/support/models/registry.rb +1 -1
- data/spec/support/models/role.rb +1 -1
- data/spec/support/models/root_category.rb +1 -1
- data/spec/support/models/sandbox/app/models/app_models_message.rb +0 -1
- data/spec/support/models/sandbox/lib/models/lib_models_message.rb +0 -1
- data/spec/support/models/sandbox/sandbox_message.rb +0 -1
- data/spec/support/models/sandbox/sandbox_user.rb +0 -1
- data/spec/support/models/sandbox/subdir/sandbox_comment.rb +0 -1
- data/spec/support/models/sandwich.rb +1 -1
- data/spec/support/models/scheduler.rb +0 -1
- data/spec/support/models/school.rb +0 -1
- data/spec/support/models/scribe.rb +1 -1
- data/spec/support/models/sealer.rb +0 -1
- data/spec/support/models/seat.rb +0 -1
- data/spec/support/models/seo.rb +1 -1
- data/spec/support/models/series.rb +1 -1
- data/spec/support/models/server.rb +1 -1
- data/spec/support/models/service.rb +2 -2
- data/spec/support/models/shape.rb +3 -3
- data/spec/support/models/shelf.rb +1 -1
- data/spec/support/models/shield.rb +2 -2
- data/spec/support/models/shipment_address.rb +0 -1
- data/spec/support/models/shipping_container.rb +1 -1
- data/spec/support/models/shipping_pack.rb +0 -1
- data/spec/support/models/shirt.rb +0 -1
- data/spec/support/models/shop.rb +2 -2
- data/spec/support/models/short_agent.rb +0 -1
- data/spec/support/models/short_quiz.rb +1 -1
- data/spec/support/models/simple.rb +1 -1
- data/spec/support/models/slave.rb +1 -1
- data/spec/support/models/song.rb +1 -2
- data/spec/support/models/sound.rb +2 -2
- data/spec/support/models/spacer.rb +0 -1
- data/spec/support/models/square.rb +0 -1
- data/spec/support/models/staff.rb +0 -1
- data/spec/support/models/store_as_dup_test1.rb +2 -2
- data/spec/support/models/store_as_dup_test2.rb +1 -1
- data/spec/support/models/store_as_dup_test3.rb +2 -2
- data/spec/support/models/store_as_dup_test4.rb +1 -1
- data/spec/support/models/strategy.rb +0 -1
- data/spec/support/models/student.rb +1 -2
- data/spec/support/models/sub_item.rb +0 -1
- data/spec/support/models/subscription.rb +2 -2
- data/spec/support/models/survey.rb +2 -2
- data/spec/support/models/symptom.rb +2 -2
- data/spec/support/models/system_role.rb +2 -3
- data/spec/support/models/tag.rb +2 -2
- data/spec/support/models/target.rb +1 -1
- data/spec/support/models/template.rb +1 -1
- data/spec/support/models/thing.rb +1 -1
- data/spec/support/models/threadlocker.rb +0 -1
- data/spec/support/models/title.rb +0 -1
- data/spec/support/models/tool.rb +3 -3
- data/spec/support/models/topping.rb +1 -1
- data/spec/support/models/toy.rb +0 -1
- data/spec/support/models/track.rb +1 -1
- data/spec/support/models/translation.rb +1 -1
- data/spec/support/models/tree.rb +2 -3
- data/spec/support/models/truck.rb +0 -1
- data/spec/support/models/updatable.rb +0 -1
- data/spec/support/models/user.rb +3 -4
- data/spec/support/models/user_account.rb +3 -3
- data/spec/support/models/validation_callback.rb +4 -4
- data/spec/support/models/vehicle.rb +2 -3
- data/spec/support/models/version.rb +1 -1
- data/spec/support/models/vertex.rb +0 -1
- data/spec/support/models/vet_visit.rb +1 -1
- data/spec/support/models/video.rb +2 -2
- data/spec/support/models/video_game.rb +0 -1
- data/spec/support/models/washer.rb +0 -1
- data/spec/support/models/weapon.rb +1 -2
- data/spec/support/models/wiki_page.rb +2 -3
- data/spec/support/models/word.rb +2 -2
- data/spec/support/models/word_origin.rb +1 -2
- data/spec/support/models/writer.rb +3 -3
- data/spec/support/rails_mock.rb +7 -12
- data/spec/support/shared/time.rb +0 -1
- data/spec/support/sinatra_mock.rb +4 -2
- data/spec/support/spec_config.rb +19 -18
- metadata +14 -2
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# rubocop:todo all
|
|
3
2
|
|
|
4
3
|
module Mongoid
|
|
5
4
|
class Criteria
|
|
6
5
|
module Queryable
|
|
7
|
-
|
|
8
6
|
# An queryable selectable is selectable, in that it has the ability to select
|
|
9
7
|
# document from the database. The selectable module brings all functionality
|
|
10
8
|
# to the selectable that has to do with building MongoDB selectors.
|
|
@@ -12,13 +10,13 @@ module Mongoid
|
|
|
12
10
|
extend Macroable
|
|
13
11
|
|
|
14
12
|
# Constant for a LineString $geometry.
|
|
15
|
-
LINE_STRING =
|
|
13
|
+
LINE_STRING = 'LineString'
|
|
16
14
|
|
|
17
15
|
# Constant for a Point $geometry.
|
|
18
|
-
POINT =
|
|
16
|
+
POINT = 'Point'
|
|
19
17
|
|
|
20
18
|
# Constant for a Polygon $geometry.
|
|
21
|
-
POLYGON =
|
|
19
|
+
POLYGON = 'Polygon'
|
|
22
20
|
|
|
23
21
|
# @attribute [rw] negating If the next expression is negated.
|
|
24
22
|
# @attribute [rw] selector The query selector.
|
|
@@ -43,27 +41,23 @@ module Mongoid
|
|
|
43
41
|
end
|
|
44
42
|
|
|
45
43
|
criteria.inject(clone) do |query, condition|
|
|
46
|
-
if condition.nil?
|
|
47
|
-
raise Errors::CriteriaArgumentRequired, :all
|
|
48
|
-
end
|
|
44
|
+
raise Errors::CriteriaArgumentRequired, :all if condition.nil?
|
|
49
45
|
|
|
50
46
|
condition = expand_condition_to_array_values(condition)
|
|
51
47
|
|
|
52
48
|
if strategy
|
|
53
|
-
send(strategy, condition,
|
|
49
|
+
send(strategy, condition, '$all')
|
|
54
50
|
else
|
|
55
51
|
condition.inject(query) do |_query, (field, value)|
|
|
56
|
-
v = {'$all' => value}
|
|
57
|
-
if negating?
|
|
58
|
-
v = {'$not' => v}
|
|
59
|
-
end
|
|
52
|
+
v = { '$all' => value }
|
|
53
|
+
v = { '$not' => v } if negating?
|
|
60
54
|
_query.add_field_expression(field.to_s, v)
|
|
61
55
|
end
|
|
62
56
|
end
|
|
63
57
|
end.reset_strategies!
|
|
64
58
|
end
|
|
65
|
-
alias
|
|
66
|
-
key :all, :union,
|
|
59
|
+
alias all_in all
|
|
60
|
+
key :all, :union, '$all'
|
|
67
61
|
|
|
68
62
|
# Add the $and criterion.
|
|
69
63
|
#
|
|
@@ -76,10 +70,8 @@ module Mongoid
|
|
|
76
70
|
#
|
|
77
71
|
# @return [ Selectable ] The new selectable.
|
|
78
72
|
def and(*criteria)
|
|
79
|
-
_mongoid_flatten_arrays(criteria).inject(
|
|
80
|
-
if new_s.is_a?(Selectable)
|
|
81
|
-
new_s = new_s.selector
|
|
82
|
-
end
|
|
73
|
+
_mongoid_flatten_arrays(criteria).inject(clone) do |c, new_s|
|
|
74
|
+
new_s = new_s.selector if new_s.is_a?(Selectable)
|
|
83
75
|
normalized = _mongoid_expand_keys(new_s)
|
|
84
76
|
normalized.each do |k, v|
|
|
85
77
|
k = k.to_s
|
|
@@ -90,16 +82,15 @@ module Mongoid
|
|
|
90
82
|
# we can add to existing conditions.
|
|
91
83
|
# Otherwise use $and.
|
|
92
84
|
if v.is_a?(Hash) &&
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
then
|
|
85
|
+
v.length == 1 &&
|
|
86
|
+
(new_k = v.keys.first).start_with?('$') &&
|
|
87
|
+
(existing_kv = c.selector[k]).is_a?(Hash) &&
|
|
88
|
+
!existing_kv.key?(new_k) &&
|
|
89
|
+
existing_kv.keys.all? { |sub_k| sub_k.start_with?('$') }
|
|
99
90
|
merged_v = c.selector[k].merge(v)
|
|
100
91
|
c.selector.store(k, merged_v)
|
|
101
92
|
else
|
|
102
|
-
c = c.send(:__multi__, [k => v], '$and')
|
|
93
|
+
c = c.send(:__multi__, [ { k => v } ], '$and')
|
|
103
94
|
end
|
|
104
95
|
else
|
|
105
96
|
c.selector.store(k, v)
|
|
@@ -108,7 +99,7 @@ module Mongoid
|
|
|
108
99
|
c
|
|
109
100
|
end
|
|
110
101
|
end
|
|
111
|
-
alias
|
|
102
|
+
alias all_of and
|
|
112
103
|
|
|
113
104
|
# Add the range selection.
|
|
114
105
|
#
|
|
@@ -122,14 +113,12 @@ module Mongoid
|
|
|
122
113
|
#
|
|
123
114
|
# @return [ Selectable ] The cloned selectable.
|
|
124
115
|
def between(criterion)
|
|
125
|
-
if criterion.nil?
|
|
126
|
-
raise Errors::CriteriaArgumentRequired, :between
|
|
127
|
-
end
|
|
116
|
+
raise Errors::CriteriaArgumentRequired, :between if criterion.nil?
|
|
128
117
|
|
|
129
118
|
selection(criterion) do |selector, field, value|
|
|
130
119
|
selector.store(
|
|
131
120
|
field,
|
|
132
|
-
{
|
|
121
|
+
{ '$gte' => value.min, '$lte' => value.max }
|
|
133
122
|
)
|
|
134
123
|
end
|
|
135
124
|
end
|
|
@@ -152,13 +141,11 @@ module Mongoid
|
|
|
152
141
|
#
|
|
153
142
|
# @return [ Selectable ] The cloned selectable.
|
|
154
143
|
def elem_match(criterion)
|
|
155
|
-
if criterion.nil?
|
|
156
|
-
raise Errors::CriteriaArgumentRequired, :elem_match
|
|
157
|
-
end
|
|
144
|
+
raise Errors::CriteriaArgumentRequired, :elem_match if criterion.nil?
|
|
158
145
|
|
|
159
|
-
and_with_operator(criterion,
|
|
146
|
+
and_with_operator(criterion, '$elemMatch')
|
|
160
147
|
end
|
|
161
|
-
key :elem_match, :override,
|
|
148
|
+
key :elem_match, :override, '$elemMatch'
|
|
162
149
|
|
|
163
150
|
# Add the $exists selection.
|
|
164
151
|
#
|
|
@@ -175,15 +162,13 @@ module Mongoid
|
|
|
175
162
|
#
|
|
176
163
|
# @return [ Selectable ] The cloned selectable.
|
|
177
164
|
def exists(criterion)
|
|
178
|
-
if criterion.nil?
|
|
179
|
-
raise Errors::CriteriaArgumentRequired, :exists
|
|
180
|
-
end
|
|
165
|
+
raise Errors::CriteriaArgumentRequired, :exists if criterion.nil?
|
|
181
166
|
|
|
182
|
-
typed_override(criterion,
|
|
167
|
+
typed_override(criterion, '$exists') do |value|
|
|
183
168
|
Mongoid::Boolean.evolve(value)
|
|
184
169
|
end
|
|
185
170
|
end
|
|
186
|
-
key :exists, :override,
|
|
171
|
+
key :exists, :override, '$exists' do |value|
|
|
187
172
|
Mongoid::Boolean.evolve(value)
|
|
188
173
|
end
|
|
189
174
|
|
|
@@ -222,26 +207,24 @@ module Mongoid
|
|
|
222
207
|
#
|
|
223
208
|
# @return [ Selectable ] The cloned selectable.
|
|
224
209
|
def geo_spatial(criterion)
|
|
225
|
-
if criterion.nil?
|
|
226
|
-
raise Errors::CriteriaArgumentRequired, :geo_spatial
|
|
227
|
-
end
|
|
210
|
+
raise Errors::CriteriaArgumentRequired, :geo_spatial if criterion.nil?
|
|
228
211
|
|
|
229
212
|
__merge__(criterion)
|
|
230
213
|
end
|
|
231
214
|
|
|
232
|
-
key :intersects_line, :override,
|
|
233
|
-
{
|
|
215
|
+
key :intersects_line, :override, '$geoIntersects', '$geometry' do |value|
|
|
216
|
+
{ 'type' => LINE_STRING, 'coordinates' => value }
|
|
234
217
|
end
|
|
235
|
-
key :intersects_point, :override,
|
|
236
|
-
{
|
|
218
|
+
key :intersects_point, :override, '$geoIntersects', '$geometry' do |value|
|
|
219
|
+
{ 'type' => POINT, 'coordinates' => value }
|
|
237
220
|
end
|
|
238
|
-
key :intersects_polygon, :override,
|
|
239
|
-
{
|
|
221
|
+
key :intersects_polygon, :override, '$geoIntersects', '$geometry' do |value|
|
|
222
|
+
{ 'type' => POLYGON, 'coordinates' => value }
|
|
240
223
|
end
|
|
241
|
-
key :within_polygon, :override,
|
|
242
|
-
{
|
|
224
|
+
key :within_polygon, :override, '$geoWithin', '$geometry' do |value|
|
|
225
|
+
{ 'type' => POLYGON, 'coordinates' => value }
|
|
243
226
|
end
|
|
244
|
-
key :within_box, :override,
|
|
227
|
+
key :within_box, :override, '$geoWithin', '$box'
|
|
245
228
|
|
|
246
229
|
# Add the $eq criterion to the selector.
|
|
247
230
|
#
|
|
@@ -255,13 +238,11 @@ module Mongoid
|
|
|
255
238
|
#
|
|
256
239
|
# @return [ Selectable ] The cloned selectable.
|
|
257
240
|
def eq(criterion)
|
|
258
|
-
if criterion.nil?
|
|
259
|
-
raise Errors::CriteriaArgumentRequired, :eq
|
|
260
|
-
end
|
|
241
|
+
raise Errors::CriteriaArgumentRequired, :eq if criterion.nil?
|
|
261
242
|
|
|
262
|
-
and_with_operator(criterion,
|
|
243
|
+
and_with_operator(criterion, '$eq')
|
|
263
244
|
end
|
|
264
|
-
key :eq, :override,
|
|
245
|
+
key :eq, :override, '$eq'
|
|
265
246
|
|
|
266
247
|
# Add the $gt criterion to the selector.
|
|
267
248
|
#
|
|
@@ -275,13 +256,11 @@ module Mongoid
|
|
|
275
256
|
#
|
|
276
257
|
# @return [ Selectable ] The cloned selectable.
|
|
277
258
|
def gt(criterion)
|
|
278
|
-
if criterion.nil?
|
|
279
|
-
raise Errors::CriteriaArgumentRequired, :gt
|
|
280
|
-
end
|
|
259
|
+
raise Errors::CriteriaArgumentRequired, :gt if criterion.nil?
|
|
281
260
|
|
|
282
|
-
and_with_operator(criterion,
|
|
261
|
+
and_with_operator(criterion, '$gt')
|
|
283
262
|
end
|
|
284
|
-
key :gt, :override,
|
|
263
|
+
key :gt, :override, '$gt'
|
|
285
264
|
|
|
286
265
|
# Add the $gte criterion to the selector.
|
|
287
266
|
#
|
|
@@ -295,13 +274,11 @@ module Mongoid
|
|
|
295
274
|
#
|
|
296
275
|
# @return [ Selectable ] The cloned selectable.
|
|
297
276
|
def gte(criterion)
|
|
298
|
-
if criterion.nil?
|
|
299
|
-
raise Errors::CriteriaArgumentRequired, :gte
|
|
300
|
-
end
|
|
277
|
+
raise Errors::CriteriaArgumentRequired, :gte if criterion.nil?
|
|
301
278
|
|
|
302
|
-
and_with_operator(criterion,
|
|
279
|
+
and_with_operator(criterion, '$gte')
|
|
303
280
|
end
|
|
304
|
-
key :gte, :override,
|
|
281
|
+
key :gte, :override, '$gte'
|
|
305
282
|
|
|
306
283
|
# Adds the $in selection to the selectable.
|
|
307
284
|
#
|
|
@@ -318,26 +295,22 @@ module Mongoid
|
|
|
318
295
|
#
|
|
319
296
|
# @return [ Selectable ] The cloned selectable.
|
|
320
297
|
def in(condition)
|
|
321
|
-
if condition.nil?
|
|
322
|
-
raise Errors::CriteriaArgumentRequired, :in
|
|
323
|
-
end
|
|
298
|
+
raise Errors::CriteriaArgumentRequired, :in if condition.nil?
|
|
324
299
|
|
|
325
300
|
condition = expand_condition_to_array_values(condition)
|
|
326
301
|
|
|
327
302
|
if strategy
|
|
328
|
-
send(strategy, condition,
|
|
303
|
+
send(strategy, condition, '$in')
|
|
329
304
|
else
|
|
330
305
|
condition.inject(clone) do |query, (field, value)|
|
|
331
|
-
v = {'$in' => value}
|
|
332
|
-
if negating?
|
|
333
|
-
v = {'$not' => v}
|
|
334
|
-
end
|
|
306
|
+
v = { '$in' => value }
|
|
307
|
+
v = { '$not' => v } if negating?
|
|
335
308
|
query.add_field_expression(field.to_s, v)
|
|
336
309
|
end.reset_strategies!
|
|
337
310
|
end
|
|
338
311
|
end
|
|
339
|
-
alias
|
|
340
|
-
key :in, :intersect,
|
|
312
|
+
alias any_in in
|
|
313
|
+
key :in, :intersect, '$in'
|
|
341
314
|
|
|
342
315
|
# Add the $lt criterion to the selector.
|
|
343
316
|
#
|
|
@@ -351,13 +324,11 @@ module Mongoid
|
|
|
351
324
|
#
|
|
352
325
|
# @return [ Selectable ] The cloned selectable.
|
|
353
326
|
def lt(criterion)
|
|
354
|
-
if criterion.nil?
|
|
355
|
-
raise Errors::CriteriaArgumentRequired, :lt
|
|
356
|
-
end
|
|
327
|
+
raise Errors::CriteriaArgumentRequired, :lt if criterion.nil?
|
|
357
328
|
|
|
358
|
-
and_with_operator(criterion,
|
|
329
|
+
and_with_operator(criterion, '$lt')
|
|
359
330
|
end
|
|
360
|
-
key :lt, :override,
|
|
331
|
+
key :lt, :override, '$lt'
|
|
361
332
|
|
|
362
333
|
# Add the $lte criterion to the selector.
|
|
363
334
|
#
|
|
@@ -371,13 +342,11 @@ module Mongoid
|
|
|
371
342
|
#
|
|
372
343
|
# @return [ Selectable ] The cloned selectable.
|
|
373
344
|
def lte(criterion)
|
|
374
|
-
if criterion.nil?
|
|
375
|
-
raise Errors::CriteriaArgumentRequired, :lte
|
|
376
|
-
end
|
|
345
|
+
raise Errors::CriteriaArgumentRequired, :lte if criterion.nil?
|
|
377
346
|
|
|
378
|
-
and_with_operator(criterion,
|
|
347
|
+
and_with_operator(criterion, '$lte')
|
|
379
348
|
end
|
|
380
|
-
key :lte, :override,
|
|
349
|
+
key :lte, :override, '$lte'
|
|
381
350
|
|
|
382
351
|
# Add a $maxDistance selection to the selectable.
|
|
383
352
|
#
|
|
@@ -388,12 +357,10 @@ module Mongoid
|
|
|
388
357
|
#
|
|
389
358
|
# @return [ Selectable ] The cloned selectable.
|
|
390
359
|
def max_distance(criterion)
|
|
391
|
-
if criterion.nil?
|
|
392
|
-
raise Errors::CriteriaArgumentRequired, :max_distance
|
|
393
|
-
end
|
|
360
|
+
raise Errors::CriteriaArgumentRequired, :max_distance if criterion.nil?
|
|
394
361
|
|
|
395
362
|
# $maxDistance must be given together with $near
|
|
396
|
-
__add__(criterion,
|
|
363
|
+
__add__(criterion, '$maxDistance')
|
|
397
364
|
end
|
|
398
365
|
|
|
399
366
|
# Adds $mod selection to the selectable.
|
|
@@ -408,13 +375,11 @@ module Mongoid
|
|
|
408
375
|
#
|
|
409
376
|
# @return [ Selectable ] The cloned selectable.
|
|
410
377
|
def mod(criterion)
|
|
411
|
-
if criterion.nil?
|
|
412
|
-
raise Errors::CriteriaArgumentRequired, :mod
|
|
413
|
-
end
|
|
378
|
+
raise Errors::CriteriaArgumentRequired, :mod if criterion.nil?
|
|
414
379
|
|
|
415
|
-
and_with_operator(criterion,
|
|
380
|
+
and_with_operator(criterion, '$mod')
|
|
416
381
|
end
|
|
417
|
-
key :mod, :override,
|
|
382
|
+
key :mod, :override, '$mod'
|
|
418
383
|
|
|
419
384
|
# Adds $ne selection to the selectable.
|
|
420
385
|
#
|
|
@@ -428,14 +393,12 @@ module Mongoid
|
|
|
428
393
|
#
|
|
429
394
|
# @return [ Selectable ] The cloned selectable.
|
|
430
395
|
def ne(criterion)
|
|
431
|
-
if criterion.nil?
|
|
432
|
-
raise Errors::CriteriaArgumentRequired, :ne
|
|
433
|
-
end
|
|
396
|
+
raise Errors::CriteriaArgumentRequired, :ne if criterion.nil?
|
|
434
397
|
|
|
435
|
-
and_with_operator(criterion,
|
|
398
|
+
and_with_operator(criterion, '$ne')
|
|
436
399
|
end
|
|
437
|
-
alias
|
|
438
|
-
key :ne, :override,
|
|
400
|
+
alias excludes ne
|
|
401
|
+
key :ne, :override, '$ne'
|
|
439
402
|
|
|
440
403
|
# Adds a $near criterion to a geo selection.
|
|
441
404
|
#
|
|
@@ -449,13 +412,11 @@ module Mongoid
|
|
|
449
412
|
#
|
|
450
413
|
# @return [ Selectable ] The cloned selectable.
|
|
451
414
|
def near(criterion)
|
|
452
|
-
if criterion.nil?
|
|
453
|
-
raise Errors::CriteriaArgumentRequired, :near
|
|
454
|
-
end
|
|
415
|
+
raise Errors::CriteriaArgumentRequired, :near if criterion.nil?
|
|
455
416
|
|
|
456
|
-
and_with_operator(criterion,
|
|
417
|
+
and_with_operator(criterion, '$near')
|
|
457
418
|
end
|
|
458
|
-
key :near, :override,
|
|
419
|
+
key :near, :override, '$near'
|
|
459
420
|
|
|
460
421
|
# Adds a $nearSphere criterion to a geo selection.
|
|
461
422
|
#
|
|
@@ -469,13 +430,11 @@ module Mongoid
|
|
|
469
430
|
#
|
|
470
431
|
# @return [ Selectable ] The cloned selectable.
|
|
471
432
|
def near_sphere(criterion)
|
|
472
|
-
if criterion.nil?
|
|
473
|
-
raise Errors::CriteriaArgumentRequired, :near_sphere
|
|
474
|
-
end
|
|
433
|
+
raise Errors::CriteriaArgumentRequired, :near_sphere if criterion.nil?
|
|
475
434
|
|
|
476
|
-
and_with_operator(criterion,
|
|
435
|
+
and_with_operator(criterion, '$nearSphere')
|
|
477
436
|
end
|
|
478
|
-
key :near_sphere, :override,
|
|
437
|
+
key :near_sphere, :override, '$nearSphere'
|
|
479
438
|
|
|
480
439
|
# Adds the $nin selection to the selectable.
|
|
481
440
|
#
|
|
@@ -492,26 +451,22 @@ module Mongoid
|
|
|
492
451
|
#
|
|
493
452
|
# @return [ Selectable ] The cloned selectable.
|
|
494
453
|
def nin(condition)
|
|
495
|
-
if condition.nil?
|
|
496
|
-
raise Errors::CriteriaArgumentRequired, :nin
|
|
497
|
-
end
|
|
454
|
+
raise Errors::CriteriaArgumentRequired, :nin if condition.nil?
|
|
498
455
|
|
|
499
456
|
condition = expand_condition_to_array_values(condition)
|
|
500
457
|
|
|
501
458
|
if strategy
|
|
502
|
-
send(strategy, condition,
|
|
459
|
+
send(strategy, condition, '$nin')
|
|
503
460
|
else
|
|
504
461
|
condition.inject(clone) do |query, (field, value)|
|
|
505
|
-
v = {'$nin' => value}
|
|
506
|
-
if negating?
|
|
507
|
-
v = {'$not' => v}
|
|
508
|
-
end
|
|
462
|
+
v = { '$nin' => value }
|
|
463
|
+
v = { '$not' => v } if negating?
|
|
509
464
|
query.add_field_expression(field.to_s, v)
|
|
510
465
|
end.reset_strategies!
|
|
511
466
|
end
|
|
512
467
|
end
|
|
513
|
-
alias
|
|
514
|
-
key :nin, :intersect,
|
|
468
|
+
alias not_in nin
|
|
469
|
+
key :nin, :intersect, '$nin'
|
|
515
470
|
|
|
516
471
|
# Adds $nor selection to the selectable.
|
|
517
472
|
#
|
|
@@ -555,32 +510,28 @@ module Mongoid
|
|
|
555
510
|
if criteria.empty?
|
|
556
511
|
dup.tap { |query| query.negating = !query.negating }
|
|
557
512
|
else
|
|
558
|
-
criteria.compact.inject(
|
|
559
|
-
if new_s.is_a?(Selectable)
|
|
560
|
-
new_s = new_s.selector
|
|
561
|
-
end
|
|
513
|
+
criteria.compact.inject(clone) do |c, new_s|
|
|
514
|
+
new_s = new_s.selector if new_s.is_a?(Selectable)
|
|
562
515
|
_mongoid_expand_keys(new_s).each do |k, v|
|
|
563
516
|
k = k.to_s
|
|
564
517
|
if c.selector[k] || k.start_with?('$')
|
|
565
|
-
c = c.send(:__multi__, [{'$nor' => [{k => v}]}], '$and')
|
|
518
|
+
c = c.send(:__multi__, [ { '$nor' => [ { k => v } ] } ], '$and')
|
|
519
|
+
elsif v.is_a?(Hash)
|
|
520
|
+
c = c.send(:__multi__, [ { '$nor' => [ { k => v } ] } ], '$and')
|
|
566
521
|
else
|
|
567
|
-
if v.is_a?(
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
negated_operator = '$ne'
|
|
574
|
-
end
|
|
575
|
-
c = c.send(:__override__, {k => v}, negated_operator)
|
|
576
|
-
end
|
|
522
|
+
negated_operator = if v.is_a?(Regexp)
|
|
523
|
+
'$not'
|
|
524
|
+
else
|
|
525
|
+
'$ne'
|
|
526
|
+
end
|
|
527
|
+
c = c.send(:__override__, { k => v }, negated_operator)
|
|
577
528
|
end
|
|
578
529
|
end
|
|
579
530
|
c
|
|
580
531
|
end
|
|
581
532
|
end
|
|
582
533
|
end
|
|
583
|
-
key :not, :override,
|
|
534
|
+
key :not, :override, '$not'
|
|
584
535
|
|
|
585
536
|
# Negate the arguments, constraining the query to only those documents
|
|
586
537
|
# that do NOT match the arguments.
|
|
@@ -604,8 +555,8 @@ module Mongoid
|
|
|
604
555
|
|
|
605
556
|
exprs = criteria.map do |criterion|
|
|
606
557
|
_mongoid_expand_keys(
|
|
607
|
-
|
|
608
|
-
|
|
558
|
+
criterion.is_a?(Selectable) ? criterion.selector : criterion
|
|
559
|
+
)
|
|
609
560
|
end
|
|
610
561
|
|
|
611
562
|
self.and('$nor' => exprs)
|
|
@@ -690,9 +641,9 @@ module Mongoid
|
|
|
690
641
|
else
|
|
691
642
|
Hash[criterion.map do |k, v|
|
|
692
643
|
if k.is_a?(Symbol)
|
|
693
|
-
[k.to_s, v]
|
|
644
|
+
[ k.to_s, v ]
|
|
694
645
|
else
|
|
695
|
-
[k, v]
|
|
646
|
+
[ k, v ]
|
|
696
647
|
end
|
|
697
648
|
end]
|
|
698
649
|
end
|
|
@@ -716,15 +667,13 @@ module Mongoid
|
|
|
716
667
|
#
|
|
717
668
|
# @return [ Selectable ] The cloned selectable.
|
|
718
669
|
def with_size(criterion)
|
|
719
|
-
if criterion.nil?
|
|
720
|
-
raise Errors::CriteriaArgumentRequired, :with_size
|
|
721
|
-
end
|
|
670
|
+
raise Errors::CriteriaArgumentRequired, :with_size if criterion.nil?
|
|
722
671
|
|
|
723
|
-
typed_override(criterion,
|
|
672
|
+
typed_override(criterion, '$size') do |value|
|
|
724
673
|
::Integer.evolve(value)
|
|
725
674
|
end
|
|
726
675
|
end
|
|
727
|
-
key :with_size, :override,
|
|
676
|
+
key :with_size, :override, '$size' do |value|
|
|
728
677
|
::Integer.evolve(value)
|
|
729
678
|
end
|
|
730
679
|
|
|
@@ -742,15 +691,13 @@ module Mongoid
|
|
|
742
691
|
#
|
|
743
692
|
# @return [ Selectable ] The cloned selectable.
|
|
744
693
|
def with_type(criterion)
|
|
745
|
-
if criterion.nil?
|
|
746
|
-
raise Errors::CriteriaArgumentRequired, :with_type
|
|
747
|
-
end
|
|
694
|
+
raise Errors::CriteriaArgumentRequired, :with_type if criterion.nil?
|
|
748
695
|
|
|
749
|
-
typed_override(criterion,
|
|
696
|
+
typed_override(criterion, '$type') do |value|
|
|
750
697
|
::Integer.evolve(value)
|
|
751
698
|
end
|
|
752
699
|
end
|
|
753
|
-
key :with_type, :override,
|
|
700
|
+
key :with_type, :override, '$type' do |value|
|
|
754
701
|
::Integer.evolve(value)
|
|
755
702
|
end
|
|
756
703
|
|
|
@@ -774,12 +721,10 @@ module Mongoid
|
|
|
774
721
|
#
|
|
775
722
|
# @return [ Selectable ] The cloned selectable.
|
|
776
723
|
def text_search(terms, opts = nil)
|
|
777
|
-
if terms.nil?
|
|
778
|
-
raise Errors::CriteriaArgumentRequired, :terms
|
|
779
|
-
end
|
|
724
|
+
raise Errors::CriteriaArgumentRequired, :terms if terms.nil?
|
|
780
725
|
|
|
781
726
|
clone.tap do |query|
|
|
782
|
-
criterion = {'$text' => { '$search' => terms }}
|
|
727
|
+
criterion = { '$text' => { '$search' => terms } }
|
|
783
728
|
criterion['$text'].merge!(opts) if opts
|
|
784
729
|
if query.selector['$text']
|
|
785
730
|
# Per https://www.mongodb.com/docs/manual/reference/operator/query/text/
|
|
@@ -788,7 +733,7 @@ module Mongoid
|
|
|
788
733
|
# overwriting previous text search condition with the currently
|
|
789
734
|
# given one.
|
|
790
735
|
Mongoid.logger.warn('Multiple $text expressions per query are not currently supported by the server')
|
|
791
|
-
query.selector = {'$and' => [query.selector]}.merge(criterion)
|
|
736
|
+
query.selector = { '$and' => [ query.selector ] }.merge(criterion)
|
|
792
737
|
else
|
|
793
738
|
query.selector = query.selector.merge(criterion)
|
|
794
739
|
end
|
|
@@ -810,10 +755,10 @@ module Mongoid
|
|
|
810
755
|
#
|
|
811
756
|
# @return [ Selectable ] The cloned selectable.
|
|
812
757
|
def where(*criteria)
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
758
|
+
return clone.reset_strategies! if criteria.empty?
|
|
759
|
+
|
|
760
|
+
criteria.inject(self) do |query, criterion|
|
|
761
|
+
raise Errors::CriteriaArgumentRequired, :where if criterion.nil?
|
|
817
762
|
|
|
818
763
|
# We need to save the criterion in an instance variable so
|
|
819
764
|
# Modifiable methods know how to create a polymorphic object.
|
|
@@ -823,15 +768,13 @@ module Mongoid
|
|
|
823
768
|
# only ever specify one criterion to #where.
|
|
824
769
|
@criterion = criterion
|
|
825
770
|
if criterion.is_a?(String)
|
|
826
|
-
js_query(criterion)
|
|
771
|
+
query.js_query(criterion)
|
|
827
772
|
else
|
|
828
|
-
expr_query(criterion)
|
|
773
|
+
query.expr_query(criterion)
|
|
829
774
|
end
|
|
830
|
-
end
|
|
775
|
+
end
|
|
831
776
|
end
|
|
832
777
|
|
|
833
|
-
private
|
|
834
|
-
|
|
835
778
|
# Adds the specified expression to the query.
|
|
836
779
|
#
|
|
837
780
|
# Criterion must be a hash in one of the following forms:
|
|
@@ -850,10 +793,8 @@ module Mongoid
|
|
|
850
793
|
# @return [ Selectable ] The cloned selectable.
|
|
851
794
|
# @api private
|
|
852
795
|
def expr_query(criterion)
|
|
853
|
-
if criterion.nil?
|
|
854
|
-
|
|
855
|
-
end
|
|
856
|
-
unless Hash === criterion
|
|
796
|
+
raise ArgumentError, 'Criterion cannot be nil here' if criterion.nil?
|
|
797
|
+
unless criterion.is_a?(Hash)
|
|
857
798
|
raise Errors::InvalidQuery, "Expression must be a Hash: #{Errors::InvalidQuery.truncate_expr(criterion)}"
|
|
858
799
|
end
|
|
859
800
|
|
|
@@ -872,25 +813,6 @@ module Mongoid
|
|
|
872
813
|
end
|
|
873
814
|
end
|
|
874
815
|
|
|
875
|
-
# Force the values of the criterion to be evolved.
|
|
876
|
-
#
|
|
877
|
-
# @api private
|
|
878
|
-
#
|
|
879
|
-
# @example Force values to booleans.
|
|
880
|
-
# selectable.force_typing(criterion) do |val|
|
|
881
|
-
# Boolean.evolve(val)
|
|
882
|
-
# end
|
|
883
|
-
#
|
|
884
|
-
# @param [ Hash ] criterion The criterion.
|
|
885
|
-
def typed_override(criterion, operator)
|
|
886
|
-
if criterion
|
|
887
|
-
criterion.transform_values! do |value|
|
|
888
|
-
yield(value)
|
|
889
|
-
end
|
|
890
|
-
end
|
|
891
|
-
__override__(criterion, operator)
|
|
892
|
-
end
|
|
893
|
-
|
|
894
816
|
# Create a javascript selection.
|
|
895
817
|
#
|
|
896
818
|
# @api private
|
|
@@ -905,7 +827,7 @@ module Mongoid
|
|
|
905
827
|
clone.tap do |query|
|
|
906
828
|
if negating?
|
|
907
829
|
query.add_operator_expression('$and',
|
|
908
|
-
|
|
830
|
+
[ { '$nor' => [ { '$where' => criterion } ] } ])
|
|
909
831
|
else
|
|
910
832
|
query.add_operator_expression('$where', criterion)
|
|
911
833
|
end
|
|
@@ -913,6 +835,23 @@ module Mongoid
|
|
|
913
835
|
end
|
|
914
836
|
end
|
|
915
837
|
|
|
838
|
+
private
|
|
839
|
+
|
|
840
|
+
# Force the values of the criterion to be evolved.
|
|
841
|
+
#
|
|
842
|
+
# @api private
|
|
843
|
+
#
|
|
844
|
+
# @example Force values to booleans.
|
|
845
|
+
# selectable.force_typing(criterion) do |val|
|
|
846
|
+
# Boolean.evolve(val)
|
|
847
|
+
# end
|
|
848
|
+
#
|
|
849
|
+
# @param [ Hash ] criterion The criterion.
|
|
850
|
+
def typed_override(criterion, operator, &block)
|
|
851
|
+
criterion.transform_values!(&block) if criterion
|
|
852
|
+
__override__(criterion, operator)
|
|
853
|
+
end
|
|
854
|
+
|
|
916
855
|
# Take the provided criterion and store it as a selection in the query
|
|
917
856
|
# selector.
|
|
918
857
|
#
|
|
@@ -935,7 +874,6 @@ module Mongoid
|
|
|
935
874
|
end
|
|
936
875
|
|
|
937
876
|
class << self
|
|
938
|
-
|
|
939
877
|
# Get the methods on the selectable that can be forwarded to from a model.
|
|
940
878
|
#
|
|
941
879
|
# @example Get the forwardable methods.
|
|
@@ -944,7 +882,7 @@ module Mongoid
|
|
|
944
882
|
# @return [ Array<Symbol> ] The names of the forwardable methods.
|
|
945
883
|
def forwardables
|
|
946
884
|
public_instance_methods(false) -
|
|
947
|
-
[
|
|
885
|
+
%i[negating negating= negating? selector selector=]
|
|
948
886
|
end
|
|
949
887
|
end
|
|
950
888
|
end
|