123456789_123456789_123456789_123456789_123456789_

Module: Mongoid

Relationships & Source Files
Namespace Children
Modules:
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: lib/mongoid.rb,
lib/mongoid/association.rb,
lib/mongoid/atomic.rb,
lib/mongoid/atomic_update_preparer.rb,
lib/mongoid/attributes.rb,
lib/mongoid/cacheable.rb,
lib/mongoid/changeable.rb,
lib/mongoid/clients.rb,
lib/mongoid/collection_configurable.rb,
lib/mongoid/composable.rb,
lib/mongoid/config.rb,
lib/mongoid/contextual.rb,
lib/mongoid/copyable.rb,
lib/mongoid/criteria.rb,
lib/mongoid/deprecable.rb,
lib/mongoid/deprecation.rb,
lib/mongoid/document.rb,
lib/mongoid/encryptable.rb,
lib/mongoid/equality.rb,
lib/mongoid/evolvable.rb,
lib/mongoid/factory.rb,
lib/mongoid/fields.rb,
lib/mongoid/findable.rb,
lib/mongoid/identifiable.rb,
lib/mongoid/indexable.rb,
lib/mongoid/inspectable.rb,
lib/mongoid/interceptable.rb,
lib/mongoid/loadable.rb,
lib/mongoid/loggable.rb,
lib/mongoid/matchable.rb,
lib/mongoid/matcher.rb,
lib/mongoid/model_resolver.rb,
lib/mongoid/persistable.rb,
lib/mongoid/persistence_context.rb,
lib/mongoid/positional.rb,
lib/mongoid/reloadable.rb,
lib/mongoid/scopable.rb,
lib/mongoid/search_indexable.rb,
lib/mongoid/selectable.rb,
lib/mongoid/serializable.rb,
lib/mongoid/shardable.rb,
lib/mongoid/stateful.rb,
lib/mongoid/stringified_symbol.rb,
lib/mongoid/threaded.rb,
lib/mongoid/timestamps.rb,
lib/mongoid/touchable.rb,
lib/mongoid/traversable.rb,
lib/mongoid/utils.rb,
lib/mongoid/validatable.rb,
lib/mongoid/version.rb,
lib/mongoid/warnings.rb,
lib/mongoid/association/accessors.rb,
lib/mongoid/association/bindable.rb,
lib/mongoid/association/builders.rb,
lib/mongoid/association/constrainable.rb,
lib/mongoid/association/depending.rb,
lib/mongoid/association/eager.rb,
lib/mongoid/association/eager_loadable.rb,
lib/mongoid/association/macros.rb,
lib/mongoid/association/many.rb,
lib/mongoid/association/marshalable.rb,
lib/mongoid/association/nested.rb,
lib/mongoid/association/one.rb,
lib/mongoid/association/options.rb,
lib/mongoid/association/proxy.rb,
lib/mongoid/association/reflections.rb,
lib/mongoid/association/relatable.rb,
lib/mongoid/association/embedded/batchable.rb,
lib/mongoid/association/embedded/cyclic.rb,
lib/mongoid/association/embedded/eager.rb,
lib/mongoid/association/embedded/embedded_in.rb,
lib/mongoid/association/embedded/embeds_many.rb,
lib/mongoid/association/embedded/embeds_one.rb,
lib/mongoid/association/embedded/embedded_in/binding.rb,
lib/mongoid/association/embedded/embedded_in/buildable.rb,
lib/mongoid/association/embedded/embedded_in/proxy.rb,
lib/mongoid/association/embedded/embeds_many/binding.rb,
lib/mongoid/association/embedded/embeds_many/buildable.rb,
lib/mongoid/association/embedded/embeds_many/proxy.rb,
lib/mongoid/association/embedded/embeds_one/binding.rb,
lib/mongoid/association/embedded/embeds_one/buildable.rb,
lib/mongoid/association/embedded/embeds_one/proxy.rb,
lib/mongoid/association/nested/many.rb,
lib/mongoid/association/nested/nested_buildable.rb,
lib/mongoid/association/nested/one.rb,
lib/mongoid/association/referenced/auto_save.rb,
lib/mongoid/association/referenced/belongs_to.rb,
lib/mongoid/association/referenced/counter_cache.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many.rb,
lib/mongoid/association/referenced/has_many.rb,
lib/mongoid/association/referenced/has_one.rb,
lib/mongoid/association/referenced/syncable.rb,
lib/mongoid/association/referenced/with_polymorphic_criteria.rb,
lib/mongoid/association/referenced/belongs_to/binding.rb,
lib/mongoid/association/referenced/belongs_to/buildable.rb,
lib/mongoid/association/referenced/belongs_to/eager.rb,
lib/mongoid/association/referenced/belongs_to/proxy.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/eager.rb,
lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb,
lib/mongoid/association/referenced/has_many/binding.rb,
lib/mongoid/association/referenced/has_many/buildable.rb,
lib/mongoid/association/referenced/has_many/eager.rb,
lib/mongoid/association/referenced/has_many/enumerable.rb,
lib/mongoid/association/referenced/has_many/proxy.rb,
lib/mongoid/association/referenced/has_one/binding.rb,
lib/mongoid/association/referenced/has_one/buildable.rb,
lib/mongoid/association/referenced/has_one/eager.rb,
lib/mongoid/association/referenced/has_one/proxy.rb,
lib/mongoid/atomic/modifiers.rb,
lib/mongoid/atomic/paths/embedded.rb,
lib/mongoid/atomic/paths/root.rb,
lib/mongoid/atomic/paths/embedded/many.rb,
lib/mongoid/atomic/paths/embedded/one.rb,
lib/mongoid/attributes/dynamic.rb,
lib/mongoid/attributes/embedded.rb,
lib/mongoid/attributes/nested.rb,
lib/mongoid/attributes/processing.rb,
lib/mongoid/attributes/projector.rb,
lib/mongoid/attributes/readonly.rb,
lib/mongoid/clients/factory.rb,
lib/mongoid/clients/options.rb,
lib/mongoid/clients/sessions.rb,
lib/mongoid/clients/storage_options.rb,
lib/mongoid/clients/validators/storage.rb,
lib/mongoid/config/defaults.rb,
lib/mongoid/config/encryption.rb,
lib/mongoid/config/environment.rb,
lib/mongoid/config/introspection.rb,
lib/mongoid/config/options.rb,
lib/mongoid/config/validators/async_query_executor.rb,
lib/mongoid/config/validators/client.rb,
lib/mongoid/config/validators/option.rb,
lib/mongoid/contextual/aggregable.rb,
lib/mongoid/contextual/atomic.rb,
lib/mongoid/contextual/command.rb,
lib/mongoid/contextual/map_reduce.rb,
lib/mongoid/contextual/memory.rb,
lib/mongoid/contextual/mongo.rb,
lib/mongoid/contextual/none.rb,
lib/mongoid/contextual/queryable.rb,
lib/mongoid/contextual/aggregable/memory.rb,
lib/mongoid/contextual/aggregable/mongo.rb,
lib/mongoid/contextual/aggregable/none.rb,
lib/mongoid/contextual/mongo/documents_loader.rb,
lib/mongoid/criteria/findable.rb,
lib/mongoid/criteria/includable.rb,
lib/mongoid/criteria/inspectable.rb,
lib/mongoid/criteria/marshalable.rb,
lib/mongoid/criteria/modifiable.rb,
lib/mongoid/criteria/options.rb,
lib/mongoid/criteria/permission.rb,
lib/mongoid/criteria/queryable.rb,
lib/mongoid/criteria/scopable.rb,
lib/mongoid/criteria/translator.rb,
lib/mongoid/criteria/queryable/aggregable.rb,
lib/mongoid/criteria/queryable/expandable.rb,
lib/mongoid/criteria/queryable/key.rb,
lib/mongoid/criteria/queryable/macroable.rb,
lib/mongoid/criteria/queryable/mergeable.rb,
lib/mongoid/criteria/queryable/optional.rb,
lib/mongoid/criteria/queryable/options.rb,
lib/mongoid/criteria/queryable/pipeline.rb,
lib/mongoid/criteria/queryable/selectable.rb,
lib/mongoid/criteria/queryable/selector.rb,
lib/mongoid/criteria/queryable/smash.rb,
lib/mongoid/criteria/queryable/storable.rb,
lib/mongoid/criteria/queryable/extensions/array.rb,
lib/mongoid/criteria/queryable/extensions/big_decimal.rb,
lib/mongoid/criteria/queryable/extensions/boolean.rb,
lib/mongoid/criteria/queryable/extensions/date.rb,
lib/mongoid/criteria/queryable/extensions/date_time.rb,
lib/mongoid/criteria/queryable/extensions/hash.rb,
lib/mongoid/criteria/queryable/extensions/nil_class.rb,
lib/mongoid/criteria/queryable/extensions/numeric.rb,
lib/mongoid/criteria/queryable/extensions/object.rb,
lib/mongoid/criteria/queryable/extensions/range.rb,
lib/mongoid/criteria/queryable/extensions/regexp.rb,
lib/mongoid/criteria/queryable/extensions/set.rb,
lib/mongoid/criteria/queryable/extensions/string.rb,
lib/mongoid/criteria/queryable/extensions/symbol.rb,
lib/mongoid/criteria/queryable/extensions/time.rb,
lib/mongoid/criteria/queryable/extensions/time_with_zone.rb,
lib/mongoid/errors/ambiguous_relationship.rb,
lib/mongoid/errors/attribute_not_loaded.rb,
lib/mongoid/errors/callback.rb,
lib/mongoid/errors/create_collection_failure.rb,
lib/mongoid/errors/criteria_argument_required.rb,
lib/mongoid/errors/delete_restriction.rb,
lib/mongoid/errors/document_not_destroyed.rb,
lib/mongoid/errors/document_not_found.rb,
lib/mongoid/errors/drop_collection_failure.rb,
lib/mongoid/errors/empty_config_file.rb,
lib/mongoid/errors/immutable_attribute.rb,
lib/mongoid/errors/in_memory_collation_not_supported.rb,
lib/mongoid/errors/invalid_around_callback.rb,
lib/mongoid/errors/invalid_async_query_executor.rb,
lib/mongoid/errors/invalid_auto_encryption_configuration.rb,
lib/mongoid/errors/invalid_collection.rb,
lib/mongoid/errors/invalid_config_file.rb,
lib/mongoid/errors/invalid_config_option.rb,
lib/mongoid/errors/invalid_dependent_strategy.rb,
lib/mongoid/errors/invalid_discriminator_key_target.rb,
lib/mongoid/errors/invalid_dot_dollar_assignment.rb,
lib/mongoid/errors/invalid_elem_match_operator.rb,
lib/mongoid/errors/invalid_estimated_count_criteria.rb,
lib/mongoid/errors/invalid_estimated_count_scoping.rb,
lib/mongoid/errors/invalid_expression_operator.rb,
lib/mongoid/errors/invalid_field.rb,
lib/mongoid/errors/invalid_field_operator.rb,
lib/mongoid/errors/invalid_field_option.rb,
lib/mongoid/errors/invalid_field_type.rb,
lib/mongoid/errors/invalid_find.rb,
lib/mongoid/errors/invalid_global_executor_concurrency.rb,
lib/mongoid/errors/invalid_includes.rb,
lib/mongoid/errors/invalid_index.rb,
lib/mongoid/errors/invalid_options.rb,
lib/mongoid/errors/invalid_path.rb,
lib/mongoid/errors/invalid_persistence_option.rb,
lib/mongoid/errors/invalid_query.rb,
lib/mongoid/errors/invalid_relation.rb,
lib/mongoid/errors/invalid_relation_option.rb,
lib/mongoid/errors/invalid_scope.rb,
lib/mongoid/errors/invalid_session_nesting.rb,
lib/mongoid/errors/invalid_set_polymorphic_relation.rb,
lib/mongoid/errors/invalid_storage_options.rb,
lib/mongoid/errors/invalid_time.rb,
lib/mongoid/errors/invalid_transaction_nesting.rb,
lib/mongoid/errors/inverse_not_found.rb,
lib/mongoid/errors/mixed_client_configuration.rb,
lib/mongoid/errors/mixed_relations.rb,
lib/mongoid/errors/mongoid_error.rb,
lib/mongoid/errors/nested_attributes_metadata_not_found.rb,
lib/mongoid/errors/no_client_config.rb,
lib/mongoid/errors/no_client_database.rb,
lib/mongoid/errors/no_client_hosts.rb,
lib/mongoid/errors/no_clients_config.rb,
lib/mongoid/errors/no_default_client.rb,
lib/mongoid/errors/no_environment.rb,
lib/mongoid/errors/no_map_reduce_output.rb,
lib/mongoid/errors/no_metadata.rb,
lib/mongoid/errors/no_parent.rb,
lib/mongoid/errors/readonly_attribute.rb,
lib/mongoid/errors/readonly_document.rb,
lib/mongoid/errors/rollback.rb,
lib/mongoid/errors/scope_overwrite.rb,
lib/mongoid/errors/sessions_not_supported.rb,
lib/mongoid/errors/too_many_nested_attribute_records.rb,
lib/mongoid/errors/transaction_error.rb,
lib/mongoid/errors/transactions_not_supported.rb,
lib/mongoid/errors/unknown_attribute.rb,
lib/mongoid/errors/unknown_model.rb,
lib/mongoid/errors/unrecognized_model_alias.rb,
lib/mongoid/errors/unrecognized_resolver.rb,
lib/mongoid/errors/unregistered_class.rb,
lib/mongoid/errors/unsaved_document.rb,
lib/mongoid/errors/unsupported_javascript.rb,
lib/mongoid/errors/validations.rb,
lib/mongoid/extensions/array.rb,
lib/mongoid/extensions/big_decimal.rb,
lib/mongoid/extensions/binary.rb,
lib/mongoid/extensions/boolean.rb,
lib/mongoid/extensions/date.rb,
lib/mongoid/extensions/date_time.rb,
lib/mongoid/extensions/decimal128.rb,
lib/mongoid/extensions/false_class.rb,
lib/mongoid/extensions/float.rb,
lib/mongoid/extensions/hash.rb,
lib/mongoid/extensions/integer.rb,
lib/mongoid/extensions/module.rb,
lib/mongoid/extensions/nil_class.rb,
lib/mongoid/extensions/object.rb,
lib/mongoid/extensions/object_id.rb,
lib/mongoid/extensions/range.rb,
lib/mongoid/extensions/raw_value.rb,
lib/mongoid/extensions/regexp.rb,
lib/mongoid/extensions/set.rb,
lib/mongoid/extensions/string.rb,
lib/mongoid/extensions/symbol.rb,
lib/mongoid/extensions/time.rb,
lib/mongoid/extensions/time_with_zone.rb,
lib/mongoid/extensions/true_class.rb,
lib/mongoid/fields/encrypted.rb,
lib/mongoid/fields/foreign_key.rb,
lib/mongoid/fields/localized.rb,
lib/mongoid/fields/standard.rb,
lib/mongoid/fields/validators/macro.rb,
lib/mongoid/indexable/specification.rb,
lib/mongoid/indexable/validators/options.rb,
lib/mongoid/matcher/all.rb,
lib/mongoid/matcher/and.rb,
lib/mongoid/matcher/bits.rb,
lib/mongoid/matcher/bits_all_clear.rb,
lib/mongoid/matcher/bits_all_set.rb,
lib/mongoid/matcher/bits_any_clear.rb,
lib/mongoid/matcher/bits_any_set.rb,
lib/mongoid/matcher/elem_match.rb,
lib/mongoid/matcher/elem_match_expression.rb,
lib/mongoid/matcher/eq.rb,
lib/mongoid/matcher/eq_impl.rb,
lib/mongoid/matcher/eq_impl_with_regexp.rb,
lib/mongoid/matcher/exists.rb,
lib/mongoid/matcher/expression.rb,
lib/mongoid/matcher/expression_operator.rb,
lib/mongoid/matcher/field_expression.rb,
lib/mongoid/matcher/field_operator.rb,
lib/mongoid/matcher/gt.rb,
lib/mongoid/matcher/gte.rb,
lib/mongoid/matcher/in.rb,
lib/mongoid/matcher/lt.rb,
lib/mongoid/matcher/lte.rb,
lib/mongoid/matcher/mod.rb,
lib/mongoid/matcher/ne.rb,
lib/mongoid/matcher/nin.rb,
lib/mongoid/matcher/nor.rb,
lib/mongoid/matcher/not.rb,
lib/mongoid/matcher/or.rb,
lib/mongoid/matcher/regex.rb,
lib/mongoid/matcher/size.rb,
lib/mongoid/matcher/type.rb,
lib/mongoid/persistable/creatable.rb,
lib/mongoid/persistable/deletable.rb,
lib/mongoid/persistable/destroyable.rb,
lib/mongoid/persistable/incrementable.rb,
lib/mongoid/persistable/logical.rb,
lib/mongoid/persistable/maxable.rb,
lib/mongoid/persistable/minable.rb,
lib/mongoid/persistable/multipliable.rb,
lib/mongoid/persistable/poppable.rb,
lib/mongoid/persistable/pullable.rb,
lib/mongoid/persistable/pushable.rb,
lib/mongoid/persistable/renamable.rb,
lib/mongoid/persistable/savable.rb,
lib/mongoid/persistable/settable.rb,
lib/mongoid/persistable/unsettable.rb,
lib/mongoid/persistable/updatable.rb,
lib/mongoid/persistable/upsertable.rb,
lib/mongoid/railties/bson_object_id_serializer.rb,
lib/mongoid/railties/controller_runtime.rb,
lib/mongoid/tasks/database.rb,
lib/mongoid/tasks/encryption.rb,
lib/mongoid/threaded/lifecycle.rb,
lib/mongoid/timestamps/created.rb,
lib/mongoid/timestamps/short.rb,
lib/mongoid/timestamps/timeless.rb,
lib/mongoid/timestamps/updated.rb,
lib/mongoid/timestamps/created/short.rb,
lib/mongoid/timestamps/updated/short.rb,
lib/mongoid/validatable/associated.rb,
lib/mongoid/validatable/format.rb,
lib/mongoid/validatable/length.rb,
lib/mongoid/validatable/localizable.rb,
lib/mongoid/validatable/macros.rb,
lib/mongoid/validatable/presence.rb,
lib/mongoid/validatable/queryable.rb,
lib/mongoid/validatable/uniqueness.rb,
lib/rails/generators/mongoid_generator.rb,
lib/rails/generators/mongoid/config/config_generator.rb,
lib/rails/generators/mongoid/model/model_generator.rb

Overview

Top-level module for project.

Constant Summary

Class Attribute Summary

GlobalDiscriminatorKeyAssignment - Extended

discriminator_key=

Sets the global discriminator key name.

::Mongoid::Clients::Sessions::ClassMethods - Extended

in_transaction?

This method should be used to detect whether a persistence operation is executed inside transaction or not.

Loadable - Extended

model_paths

Returns the array of paths where the application’s model definitions are located.

model_paths=

Sets the model paths to the given array of paths.

Loggable - Extended

logger

Get the logger.

logger=

::Set the logger.

Class Method Summary

Deprecable - Extended

deprecate

Declares method(s) as deprecated.

::Mongoid::Clients::Sessions::ClassMethods - Extended

after_commit

Sets up a callback is called after a commit of a transaction.

after_create_commit

Shortcut for after_commit :hook, on: :create.

after_destroy_commit

Shortcut for after_commit :hook, on: :destroy.

after_rollback

This callback is called after a create, update, or destroy are rolled back.

after_save_commit

Shortcut for after_commit :hook, on: [ :create, :update ].

after_update_commit

Shortcut for after_commit :hook, on: :update.

transaction

Executes a block within the context of a transaction.

with_session

Execute a block within the context of a session.

_session,
assert_valid_transaction_action

Asserts that the given actions are valid for after_commit and after_rollback callbacks.

run_abort_callbacks

Runs after_rollback callbacks on modified documents.

run_commit_callbacks

Runs after_commit callbacks on modified documents.

set_options_for_callbacks!

Transforms custom options for after_commit and after_rollback callbacks into options for set_callback.

transaction_include_any_action?,
transactions_not_supported_exceptions

Driver version 2.20 introduced a new exception for reporting that transactions are not supported.

Loadable - Extended

load_model

A convenience method for loading a model’s file.

load_models

Search a list of model paths to get every model and require it, so that indexing and inheritance work in both development and production with the same results.

Loggable - Extended

default_logger

Gets the default Mongoid logger - stderr.

rails_logger

Get the ::Rails logger if loaded in a ::Rails application, otherwise nil.

Instance Method Summary

Instance Method Details

#client(name) ⇒ Mongo::Client

Convenience method for getting a named client.

Examples:

Get a named client.

Mongoid.client(:default)

Returns:

  • (Mongo::Client)

    The named client.

[ GitHub ]

  
# File 'lib/mongoid.rb', line 119

def client(name)
  Clients.with_name(name)
end

#configure(&block) ⇒ Config

Sets the Mongoid configuration options. Best used by passing a block.

Examples:

::Set up configuration options.

Mongoid.configure do |config|
  config.connect_to("mongoid_test")

  config.clients.default = {
    hosts: ["localhost:27017"],
    database: "mongoid_test",
  }
end

Using a block without an argument. Use config inside

the block to perform variable assignment.

Mongoid.configure do
  connect_to("mongoid_test")

  config.preload_models = true

Returns:

  • (Config)

    The configuration object.

[ GitHub ]

  
# File 'lib/mongoid.rb', line 77

def configure(&block)
  return Config unless block_given?

  block.arity == 0 ? Config.instance_exec(&block) : yield(Config)
end

#default_clientMongo::Client

Convenience method for getting the default client.

Examples:

Get the default client.

Mongoid.default_client

Returns:

  • (Mongo::Client)

    The default client.

[ GitHub ]

  
# File 'lib/mongoid.rb', line 89

def default_client
  Clients.default
end

#disconnect_clientstrue

Disconnect all active clients.

Examples:

Disconnect all active clients.

Mongoid.disconnect_clients

Returns:

  • (true)

    True.

[ GitHub ]

  
# File 'lib/mongoid.rb', line 99

def disconnect_clients
  Clients.disconnect
end

#persistence_context

This method is for internal use only.

Define persistence context that is used when a transaction method is called on Mongoid module.

[ GitHub ]

  
# File 'lib/mongoid.rb', line 134

def persistence_context
  PersistenceContext.get(Mongoid) || PersistenceContext.new(Mongoid)
end

RawValue(*args) ⇒ Mongoid::RawValue

Instantiates a new ::Mongoid::RawValue object. Used as a syntax shortcut.

Examples:

Create a ::Mongoid::RawValue object.

Mongoid::RawValue("Beagle")

Returns:

[ GitHub ]

  
# File 'lib/mongoid/extensions/raw_value.rb', line 13

def RawValue(*args)
  RawValue.new(*args)
end

#reconnect_clientstrue

Reconnect all active clients.

Examples:

Reconnect all active clients.

Mongoid.reconnect_clients

Returns:

  • (true)

    True.

[ GitHub ]

  
# File 'lib/mongoid.rb', line 109

def reconnect_clients
  Clients.reconnect
end

#storage_options

This method is for internal use only.

Define client that is used when a transaction method is called on Mongoid module. This MUST be the default client.

[ GitHub ]

  
# File 'lib/mongoid.rb', line 142

def storage_options
  { client: :default }
end