Module: Mongoid::Sessions::Options

Extended by:
ActiveSupport::Concern
Included in:
Criteria, Mongoid::Sessions
Defined in:
lib/mongoid/sessions/options.rb

Defined Under Namespace

Modules: ClassMethods, Threaded Classes: Proxy

Instance Method Summary collapse

Instance Method Details

#persistence_optionsObject


35
36
37
# File 'lib/mongoid/sessions/options.rb', line 35

def persistence_options
  @persistence_options
end

#with(options) ⇒ Document

Tell the next persistance operation to store in a specific collection, database or session.

Examples:

Save the current document to a different collection.

model.with(collection: "secondary").save

Save the current document to a different database.

model.with(database: "secondary").save

Save the current document to a different session.

model.with(session: "replica_set").save

Save with a combination of options.

model.with(session: "sharded", database: "secondary").save

Parameters:

  • options (Hash)

    The storage options.

Options Hash (options):

  • :collection (String, Symbol)

    The collection name.

  • :database (String, Symbol)

    The database name.

  • :session (String, Symbol)

    The session name.

Returns:

Since:

  • 3.0.0


30
31
32
33
# File 'lib/mongoid/sessions/options.rb', line 30

def with(options)
  @persistence_options = options
  self
end