Module: Mongoid

Extended by:
Mongoid, Loggable, UnitOfWork
Included in:
Mongoid
Defined in:
lib/mongoid.rb,
lib/mongoid/state.rb,
lib/mongoid/atomic.rb,
lib/mongoid/config.rb,
lib/mongoid/fields.rb,
lib/mongoid/factory.rb,
lib/mongoid/version.rb,
lib/mongoid/copyable.rb,
lib/mongoid/criteria.rb,
lib/mongoid/document.rb,
lib/mongoid/equality.rb,
lib/mongoid/findable.rb,
lib/mongoid/loggable.rb,
lib/mongoid/scopable.rb,
lib/mongoid/sessions.rb,
lib/mongoid/threaded.rb,
lib/mongoid/evolvable.rb,
lib/mongoid/indexable.rb,
lib/mongoid/matchable.rb,
lib/mongoid/relations.rb,
lib/mongoid/shardable.rb,
lib/mongoid/attributes.rb,
lib/mongoid/changeable.rb,
lib/mongoid/composable.rb,
lib/mongoid/contextual.rb,
lib/mongoid/positional.rb,
lib/mongoid/reloadable.rb,
lib/mongoid/selectable.rb,
lib/mongoid/timestamps.rb,
lib/mongoid/inspectable.rb,
lib/mongoid/persistable.rb,
lib/mongoid/traversable.rb,
lib/mongoid/validatable.rb,
lib/mongoid/identity_map.rb,
lib/mongoid/matchable/gt.rb,
lib/mongoid/matchable/in.rb,
lib/mongoid/matchable/lt.rb,
lib/mongoid/matchable/ne.rb,
lib/mongoid/matchable/or.rb,
lib/mongoid/serializable.rb,
lib/mongoid/unit_of_work.rb,
lib/mongoid/interceptable.rb,
lib/mongoid/matchable/all.rb,
lib/mongoid/matchable/and.rb,
lib/mongoid/matchable/gte.rb,
lib/mongoid/matchable/lte.rb,
lib/mongoid/matchable/nin.rb,
lib/mongoid/relations/one.rb,
lib/mongoid/config/options.rb,
lib/mongoid/extensions/set.rb,
lib/mongoid/matchable/size.rb,
lib/mongoid/relations/many.rb,
lib/mongoid/errors/callback.rb,
lib/mongoid/extensions/date.rb,
lib/mongoid/extensions/hash.rb,
lib/mongoid/extensions/time.rb,
lib/mongoid/fields/standard.rb,
lib/mongoid/relations/proxy.rb,
lib/mongoid/atomic/modifiers.rb,
lib/mongoid/contextual/eager.rb,
lib/mongoid/contextual/mongo.rb,
lib/mongoid/errors/no_parent.rb,
lib/mongoid/extensions/array.rb,
lib/mongoid/extensions/float.rb,
lib/mongoid/extensions/range.rb,
lib/mongoid/fields/localized.rb,
lib/mongoid/matchable/exists.rb,
lib/mongoid/relations/cyclic.rb,
lib/mongoid/relations/macros.rb,
lib/mongoid/sessions/factory.rb,
lib/mongoid/sessions/options.rb,
lib/mongoid/timestamps/short.rb,
lib/mongoid/atomic/paths/root.rb,
lib/mongoid/attributes/nested.rb,
lib/mongoid/contextual/atomic.rb,
lib/mongoid/contextual/memory.rb,
lib/mongoid/criteria/findable.rb,
lib/mongoid/criteria/scopable.rb,
lib/mongoid/errors/eager_load.rb,
lib/mongoid/extensions/module.rb,
lib/mongoid/extensions/object.rb,
lib/mongoid/extensions/regexp.rb,
lib/mongoid/extensions/string.rb,
lib/mongoid/extensions/symbol.rb,
lib/mongoid/matchable/default.rb,
lib/mongoid/railties/document.rb,
lib/mongoid/relations/binding.rb,
lib/mongoid/relations/builder.rb,
lib/mongoid/relations/options.rb,
lib/mongoid/attributes/dynamic.rb,
lib/mongoid/config/environment.rb,
lib/mongoid/contextual/command.rb,
lib/mongoid/errors/no_metadata.rb,
lib/mongoid/errors/validations.rb,
lib/mongoid/extensions/boolean.rb,
lib/mongoid/extensions/integer.rb,
lib/mongoid/fields/foreign_key.rb,
lib/mongoid/relations/builders.rb,
lib/mongoid/relations/metadata.rb,
lib/mongoid/sessions/mongo_uri.rb,
lib/mongoid/threaded/lifecycle.rb,
lib/mongoid/timestamps/created.rb,
lib/mongoid/timestamps/updated.rb,
lib/mongoid/validatable/format.rb,
lib/mongoid/validatable/length.rb,
lib/mongoid/validatable/macros.rb,
lib/mongoid/attributes/readonly.rb,
lib/mongoid/contextual/geo_near.rb,
lib/mongoid/criteria/modifiable.rb,
lib/mongoid/errors/invalid_find.rb,
lib/mongoid/errors/invalid_path.rb,
lib/mongoid/errors/invalid_time.rb,
lib/mongoid/persistable/logical.rb,
lib/mongoid/persistable/savable.rb,
lib/mongoid/relations/accessors.rb,
lib/mongoid/relations/auto_save.rb,
lib/mongoid/relations/cascading.rb,
lib/mongoid/relations/touchable.rb,
lib/mongoid/contextual/queryable.rb,
lib/mongoid/criteria/inspectable.rb,
lib/mongoid/criteria/marshalable.rb,
lib/mongoid/errors/invalid_field.rb,
lib/mongoid/errors/invalid_index.rb,
lib/mongoid/errors/invalid_scope.rb,
lib/mongoid/errors/mongoid_error.rb,
lib/mongoid/extensions/date_time.rb,
lib/mongoid/extensions/nil_class.rb,
lib/mongoid/extensions/object_id.rb,
lib/mongoid/persistable/poppable.rb,
lib/mongoid/persistable/pullable.rb,
lib/mongoid/persistable/pushable.rb,
lib/mongoid/persistable/settable.rb,
lib/mongoid/relations/constraint.rb,
lib/mongoid/validatable/presence.rb,
lib/mongoid/atomic/paths/embedded.rb,
lib/mongoid/attributes/processing.rb,
lib/mongoid/contextual/map_reduce.rb,
lib/mongoid/errors/no_environment.rb,
lib/mongoid/extensions/true_class.rb,
lib/mongoid/persistable/creatable.rb,
lib/mongoid/persistable/deletable.rb,
lib/mongoid/persistable/renamable.rb,
lib/mongoid/persistable/updatable.rb,
lib/mongoid/relations/conversions.rb,
lib/mongoid/relations/embedded/in.rb,
lib/mongoid/relations/marshalable.rb,
lib/mongoid/relations/polymorphic.rb,
lib/mongoid/relations/reflections.rb,
lib/mongoid/validatable/queryable.rb,
lib/mongoid/contextual/text_search.rb,
lib/mongoid/errors/invalid_options.rb,
lib/mongoid/errors/mixed_relations.rb,
lib/mongoid/errors/scope_overwrite.rb,
lib/mongoid/extensions/big_decimal.rb,
lib/mongoid/extensions/false_class.rb,
lib/mongoid/persistable/unsettable.rb,
lib/mongoid/persistable/upsertable.rb,
lib/mongoid/relations/embedded/one.rb,
lib/mongoid/validatable/associated.rb,
lib/mongoid/validatable/uniqueness.rb,
lib/mongoid/errors/invalid_includes.rb,
lib/mongoid/errors/no_session_hosts.rb,
lib/mongoid/errors/unsaved_document.rb,
lib/mongoid/fields/validators/macro.rb,
lib/mongoid/indexable/specification.rb,
lib/mongoid/persistable/destroyable.rb,
lib/mongoid/relations/counter_cache.rb,
lib/mongoid/relations/embedded/many.rb,
lib/mongoid/relations/referenced/in.rb,
lib/mongoid/validatable/localizable.rb,
lib/mongoid/config/validators/option.rb,
lib/mongoid/errors/inverse_not_found.rb,
lib/mongoid/errors/no_session_config.rb,
lib/mongoid/errors/unknown_attribute.rb,
lib/mongoid/relations/nested_builder.rb,
lib/mongoid/relations/referenced/one.rb,
lib/mongoid/timestamps/created/short.rb,
lib/mongoid/timestamps/updated/short.rb,
lib/mongoid/atomic/paths/embedded/one.rb,
lib/mongoid/config/validators/session.rb,
lib/mongoid/errors/delete_restriction.rb,
lib/mongoid/errors/document_not_found.rb,
lib/mongoid/errors/invalid_collection.rb,
lib/mongoid/errors/no_default_session.rb,
lib/mongoid/errors/no_sessions_config.rb,
lib/mongoid/errors/readonly_attribute.rb,
lib/mongoid/extensions/time_with_zone.rb,
lib/mongoid/persistable/incrementable.rb,
lib/mongoid/relations/referenced/many.rb,
lib/mongoid/relations/synchronization.rb,
lib/mongoid/atomic/paths/embedded/many.rb,
lib/mongoid/contextual/find_and_modify.rb,
lib/mongoid/errors/no_session_database.rb,
lib/mongoid/relations/cascading/delete.rb,
lib/rails/generators/mongoid_generator.rb,
lib/mongoid/contextual/aggregable/mongo.rb,
lib/mongoid/errors/invalid_field_option.rb,
lib/mongoid/errors/no_map_reduce_output.rb,
lib/mongoid/relations/cascading/destroy.rb,
lib/mongoid/relations/cascading/nullify.rb,
lib/mongoid/sessions/validators/storage.rb,
lib/mongoid/contextual/aggregable/memory.rb,
lib/mongoid/errors/invalid_config_option.rb,
lib/mongoid/indexable/validators/options.rb,
lib/mongoid/relations/cascading/restrict.rb,
lib/mongoid/relations/embedded/batchable.rb,
lib/mongoid/relations/targets/enumerable.rb,
lib/mongoid/errors/ambiguous_relationship.rb,
lib/mongoid/errors/unsupported_javascript.rb,
lib/mongoid/errors/invalid_storage_options.rb,
lib/mongoid/relations/bindings/embedded/in.rb,
lib/mongoid/relations/builders/embedded/in.rb,
lib/mongoid/relations/bindings/embedded/one.rb,
lib/mongoid/relations/builders/embedded/one.rb,
lib/mongoid/relations/bindings/embedded/many.rb,
lib/mongoid/relations/bindings/referenced/in.rb,
lib/mongoid/relations/builders/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/errors/mixed_session_configuration.rb,
lib/mongoid/relations/bindings/referenced/many.rb,
lib/mongoid/relations/builders/referenced/many.rb,
lib/rails/generators/mongoid/model/model_generator.rb,
lib/mongoid/errors/invalid_set_polymorphic_relation.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,
lib/rails/generators/mongoid/observer/observer_generator.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, Relations, Reloadable, Scopable, Selectable, Serializable, Sessions, Shardable, State, Threaded, Timestamps, Traversable, UnitOfWork, Validatable Classes: Boolean, Criteria, IdentityMap

Constant Summary collapse

MONGODB_VERSION =
"2.2.0"
VERSION =
"4.0.0"

Instance Method Summary collapse

Methods included from Loggable

logger, logger=

Methods included from UnitOfWork

unit_of_work, using_identity_map?

Instance Method Details

#configureConfig

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

Examples:

Set up configuration options.

Mongoid.configure do |config|
  config.use(name: "mongoid_test", host: "localhost", port: 27017)
end

Returns:

  • (Config)

    The configuration object.

Since:

  • 1.0.0



56
57
58
# File 'lib/mongoid.rb', line 56

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

#default_sessionMoped::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



68
69
70
# File 'lib/mongoid.rb', line 68

def default_session
  Sessions.default
end

#disconnect_sessionstrue

Disconnect all active sessions.

Examples:

Disconnect all active sessions.

Mongoid.disconnect_sessions

Returns:

  • (true)

    True.

Since:

  • 3.1.0



80
81
82
# File 'lib/mongoid.rb', line 80

def disconnect_sessions
  Sessions.disconnect
end

#session(name) ⇒ Moped::Session

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



92
93
94
# File 'lib/mongoid.rb', line 92

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