Module: Mongoid

Extended by:
Mongoid, Loggable
Included in:
Mongoid
Defined in:
lib/mongoid.rb,
lib/mongoid/atomic.rb,
lib/mongoid/fields.rb,
lib/mongoid/config.rb,
lib/mongoid/version.rb,
lib/mongoid/factory.rb,
lib/mongoid/threaded.rb,
lib/mongoid/findable.rb,
lib/mongoid/loggable.rb,
lib/mongoid/copyable.rb,
lib/mongoid/equality.rb,
lib/mongoid/sessions.rb,
lib/mongoid/document.rb,
lib/mongoid/scopable.rb,
lib/mongoid/stateful.rb,
lib/mongoid/criteria.rb,
lib/mongoid/shardable.rb,
lib/mongoid/matchable.rb,
lib/mongoid/relations.rb,
lib/mongoid/evolvable.rb,
lib/mongoid/indexable.rb,
lib/mongoid/contextual.rb,
lib/mongoid/changeable.rb,
lib/mongoid/reloadable.rb,
lib/mongoid/positional.rb,
lib/mongoid/timestamps.rb,
lib/mongoid/composable.rb,
lib/mongoid/attributes.rb,
lib/mongoid/selectable.rb,
lib/mongoid/persistable.rb,
lib/mongoid/validatable.rb,
lib/mongoid/inspectable.rb,
lib/mongoid/query_cache.rb,
lib/mongoid/traversable.rb,
lib/mongoid/matchable/lt.rb,
lib/mongoid/matchable/or.rb,
lib/mongoid/matchable/in.rb,
lib/mongoid/matchable/ne.rb,
lib/mongoid/serializable.rb,
lib/mongoid/matchable/gt.rb,
lib/mongoid/matchable/and.rb,
lib/mongoid/matchable/all.rb,
lib/mongoid/relations/one.rb,
lib/mongoid/matchable/lte.rb,
lib/mongoid/interceptable.rb,
lib/mongoid/matchable/gte.rb,
lib/mongoid/matchable/nin.rb,
lib/mongoid/log_subscriber.rb,
lib/mongoid/tasks/database.rb,
lib/mongoid/extensions/set.rb,
lib/mongoid/relations/many.rb,
lib/mongoid/config/options.rb,
lib/mongoid/matchable/size.rb,
lib/mongoid/extensions/date.rb,
lib/mongoid/contextual/none.rb,
lib/mongoid/relations/proxy.rb,
lib/mongoid/extensions/time.rb,
lib/mongoid/extensions/hash.rb,
lib/mongoid/errors/callback.rb,
lib/mongoid/relations/eager.rb,
lib/mongoid/fields/standard.rb,
lib/mongoid/sessions/options.rb,
lib/mongoid/errors/no_parent.rb,
lib/mongoid/matchable/exists.rb,
lib/mongoid/sessions/factory.rb,
lib/mongoid/atomic/modifiers.rb,
lib/mongoid/timestamps/short.rb,
lib/mongoid/relations/macros.rb,
lib/mongoid/relations/cyclic.rb,
lib/mongoid/fields/localized.rb,
lib/mongoid/extensions/float.rb,
lib/mongoid/extensions/range.rb,
lib/mongoid/extensions/array.rb,
lib/mongoid/contextual/mongo.rb,
lib/mongoid/extensions/regexp.rb,
lib/mongoid/attributes/nested.rb,
lib/mongoid/relations/builder.rb,
lib/mongoid/matchable/default.rb,
lib/mongoid/criteria/scopable.rb,
lib/mongoid/criteria/findable.rb,
lib/mongoid/errors/eager_load.rb,
lib/mongoid/relations/options.rb,
lib/mongoid/relations/binding.rb,
lib/mongoid/extensions/string.rb,
lib/mongoid/extensions/object.rb,
lib/mongoid/extensions/symbol.rb,
lib/mongoid/extensions/module.rb,
lib/mongoid/railties/document.rb,
lib/mongoid/contextual/atomic.rb,
lib/mongoid/atomic/paths/root.rb,
lib/mongoid/contextual/memory.rb,
lib/mongoid/errors/no_metadata.rb,
lib/mongoid/sessions/mongo_uri.rb,
lib/mongoid/fields/foreign_key.rb,
lib/mongoid/extensions/boolean.rb,
lib/mongoid/errors/validations.rb,
lib/mongoid/relations/metadata.rb,
lib/mongoid/timestamps/created.rb,
lib/mongoid/relations/builders.rb,
lib/mongoid/threaded/lifecycle.rb,
lib/mongoid/validatable/length.rb,
lib/mongoid/timestamps/updated.rb,
lib/mongoid/attributes/dynamic.rb,
lib/mongoid/validatable/format.rb,
lib/mongoid/validatable/macros.rb,
lib/mongoid/config/environment.rb,
lib/mongoid/contextual/command.rb,
lib/mongoid/extensions/integer.rb,
lib/mongoid/relations/cascading.rb,
lib/mongoid/criteria/modifiable.rb,
lib/mongoid/errors/invalid_find.rb,
lib/mongoid/relations/accessors.rb,
lib/mongoid/timestamps/timeless.rb,
lib/mongoid/errors/invalid_time.rb,
lib/mongoid/persistable/logical.rb,
lib/mongoid/relations/auto_save.rb,
lib/mongoid/contextual/geo_near.rb,
lib/mongoid/errors/invalid_path.rb,
lib/mongoid/criteria/permission.rb,
lib/mongoid/persistable/savable.rb,
lib/mongoid/attributes/readonly.rb,
lib/mongoid/relations/touchable.rb,
lib/mongoid/extensions/object_id.rb,
lib/mongoid/criteria/inspectable.rb,
lib/mongoid/relations/eager/base.rb,
lib/mongoid/persistable/pushable.rb,
lib/mongoid/contextual/queryable.rb,
lib/mongoid/extensions/date_time.rb,
lib/mongoid/validatable/presence.rb,
lib/mongoid/extensions/nil_class.rb,
lib/mongoid/errors/invalid_field.rb,
lib/mongoid/errors/mongoid_error.rb,
lib/mongoid/relations/constraint.rb,
lib/mongoid/persistable/poppable.rb,
lib/mongoid/persistable/settable.rb,
lib/mongoid/errors/invalid_value.rb,
lib/mongoid/persistable/pullable.rb,
lib/mongoid/criteria/marshalable.rb,
lib/mongoid/errors/invalid_index.rb,
lib/mongoid/errors/invalid_scope.rb,
lib/mongoid/relations/conversions.rb,
lib/mongoid/support/query_counter.rb,
lib/mongoid/errors/no_environment.rb,
lib/mongoid/persistable/creatable.rb,
lib/mongoid/extensions/true_class.rb,
lib/mongoid/contextual/map_reduce.rb,
lib/mongoid/relations/reflections.rb,
lib/mongoid/validatable/queryable.rb,
lib/mongoid/attributes/processing.rb,
lib/mongoid/atomic/paths/embedded.rb,
lib/mongoid/persistable/deletable.rb,
lib/mongoid/persistable/renamable.rb,
lib/mongoid/relations/polymorphic.rb,
lib/mongoid/relations/embedded/in.rb,
lib/mongoid/relations/marshalable.rb,
lib/mongoid/persistable/updatable.rb,
lib/mongoid/extensions/false_class.rb,
lib/mongoid/persistable/unsettable.rb,
lib/mongoid/extensions/big_decimal.rb,
lib/mongoid/contextual/text_search.rb,
lib/mongoid/relations/embedded/one.rb,
lib/mongoid/errors/invalid_options.rb,
lib/mongoid/validatable/uniqueness.rb,
lib/mongoid/errors/scope_overwrite.rb,
lib/mongoid/persistable/upsertable.rb,
lib/mongoid/errors/mixed_relations.rb,
lib/mongoid/validatable/associated.rb,
lib/mongoid/relations/eager/has_one.rb,
lib/mongoid/indexable/specification.rb,
lib/mongoid/persistable/destroyable.rb,
lib/mongoid/relations/embedded/many.rb,
lib/mongoid/errors/unsaved_document.rb,
lib/mongoid/errors/invalid_includes.rb,
lib/mongoid/relations/referenced/in.rb,
lib/mongoid/fields/validators/macro.rb,
lib/mongoid/relations/counter_cache.rb,
lib/mongoid/errors/no_session_hosts.rb,
lib/mongoid/validatable/localizable.rb,
lib/mongoid/sessions/thread_options.rb,
lib/mongoid/errors/no_session_config.rb,
lib/mongoid/sessions/storage_options.rb,
lib/mongoid/timestamps/updated/short.rb,
lib/mongoid/timestamps/created/short.rb,
lib/mongoid/config/validators/option.rb,
lib/mongoid/relations/nested_builder.rb,
lib/mongoid/errors/unknown_attribute.rb,
lib/mongoid/errors/inverse_not_found.rb,
lib/mongoid/relations/referenced/one.rb,
lib/mongoid/errors/readonly_document.rb,
lib/mongoid/relations/eager/has_many.rb,
lib/mongoid/relations/referenced/many.rb,
lib/mongoid/errors/document_not_found.rb,
lib/mongoid/atomic/paths/embedded/one.rb,
lib/mongoid/extensions/time_with_zone.rb,
lib/mongoid/errors/no_sessions_config.rb,
lib/mongoid/config/validators/session.rb,
lib/mongoid/errors/readonly_attribute.rb,
lib/mongoid/relations/synchronization.rb,
lib/mongoid/errors/no_default_session.rb,
lib/mongoid/errors/invalid_collection.rb,
lib/mongoid/errors/delete_restriction.rb,
lib/mongoid/persistable/incrementable.rb,
lib/mongoid/contextual/find_and_modify.rb,
lib/mongoid/relations/eager/belongs_to.rb,
lib/mongoid/atomic/paths/embedded/many.rb,
lib/mongoid/errors/no_session_database.rb,
lib/rails/generators/mongoid_generator.rb,
lib/mongoid/relations/cascading/delete.rb,
lib/mongoid/errors/no_map_reduce_output.rb,
lib/mongoid/sessions/validators/storage.rb,
lib/mongoid/relations/cascading/destroy.rb,
lib/mongoid/errors/invalid_field_option.rb,
lib/mongoid/contextual/aggregable/mongo.rb,
lib/mongoid/relations/cascading/nullify.rb,
lib/mongoid/indexable/validators/options.rb,
lib/mongoid/relations/embedded/batchable.rb,
lib/mongoid/errors/invalid_config_option.rb,
lib/mongoid/relations/cascading/restrict.rb,
lib/mongoid/relations/targets/enumerable.rb,
lib/mongoid/contextual/aggregable/memory.rb,
lib/mongoid/errors/invalid_storage_parent.rb,
lib/mongoid/errors/unsupported_javascript.rb,
lib/mongoid/errors/document_not_destroyed.rb,
lib/mongoid/errors/ambiguous_relationship.rb,
lib/mongoid/relations/bindings/embedded/in.rb,
lib/mongoid/errors/invalid_storage_options.rb,
lib/mongoid/relations/builders/embedded/in.rb,
lib/mongoid/relations/builders/embedded/one.rb,
lib/mongoid/relations/bindings/embedded/one.rb,
lib/mongoid/relations/bindings/referenced/in.rb,
lib/mongoid/relations/builders/embedded/many.rb,
lib/mongoid/relations/bindings/embedded/many.rb,
lib/mongoid/relations/builders/referenced/in.rb,
lib/mongoid/relations/bindings/referenced/one.rb,
lib/mongoid/relations/builders/referenced/one.rb,
lib/mongoid/relations/referenced/many_to_many.rb,
lib/mongoid/relations/builders/referenced/many.rb,
lib/mongoid/relations/bindings/referenced/many.rb,
lib/mongoid/errors/mixed_session_configuration.rb,
lib/rails/generators/mongoid/model/model_generator.rb,
lib/mongoid/errors/invalid_set_polymorphic_relation.rb,
lib/mongoid/relations/eager/has_and_belongs_to_many.rb,
lib/mongoid/errors/too_many_nested_attribute_records.rb,
lib/mongoid/relations/builders/nested_attributes/one.rb,
lib/rails/generators/mongoid/config/config_generator.rb,
lib/mongoid/relations/builders/nested_attributes/many.rb,
lib/mongoid/relations/bindings/referenced/many_to_many.rb,
lib/mongoid/relations/builders/referenced/many_to_many.rb,
lib/mongoid/errors/nested_attributes_metadata_not_found.rb

Defined Under Namespace

Modules: Atomic, Attributes, Changeable, Composable, Config, Contextual, Copyable, Document, Equality, Errors, Evolvable, Extensions, Factory, Fields, Findable, Generators, Indexable, Inspectable, Interceptable, Loggable, Matchable, Persistable, Positional, QueryCache, Relations, Reloadable, Scopable, Selectable, Serializable, Sessions, Shardable, Stateful, Tasks, Threaded, Timestamps, Traversable, Validatable Classes: Boolean, Criteria, LogSubscriber, QueryCounter

Constant Summary

MONGODB_VERSION =
"2.2.0"
VERSION =
"4.0.0.beta1"

Instance Method Summary (collapse)

Methods included from Loggable

logger, logger=

Instance Method Details

- (Config) configure

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")
end

Returns:

  • (Config)

    The configuration object.

Since:

  • 1.0.0



51
52
53
# File 'lib/mongoid.rb', line 51

def configure
  block_given? ? yield(Config) : Config
end

- (Moped::Session) default_session

Convenience method for getting the default session.

Examples:

Get the default session.

Mongoid.default_session

Returns:

  • (Moped::Session)

    The default session.

Since:

  • 3.0.0



63
64
65
# File 'lib/mongoid.rb', line 63

def default_session
  Sessions.default
end

- (true) disconnect_sessions

Disconnect all active sessions.

Examples:

Disconnect all active sessions.

Mongoid.disconnect_sessions

Returns:

  • (true)

    True.

Since:

  • 3.1.0



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

def disconnect_sessions
  Sessions.disconnect
end

- (Moped::Session) session(name)

Convenience method for getting a named session.

Examples:

Get a named session.

Mongoid.session(:default)

Returns:

  • (Moped::Session)

    The named session.

Since:

  • 3.0.0



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

def session(name)
  Sessions.with_name(name)
end