module Mongoid::Sessions::Options::ClassMethods

Public Instance Methods

collection_name() click to toggle source
Calls superclass method
# File lib/mongoid/sessions/options.rb, line 97
def collection_name
  if persistence_options && v = persistence_options[:collection]
    return v.to_sym
  end
  super
end
database_name() click to toggle source
Calls superclass method
# File lib/mongoid/sessions/options.rb, line 104
def database_name
  if persistence_options && v = persistence_options[:database]
    return v.to_sym
  end
  super
end
session_name() click to toggle source
Calls superclass method
# File lib/mongoid/sessions/options.rb, line 90
def session_name
  if persistence_options && v = persistence_options[:session]
    return v.to_sym
  end
  super
end
with(options) click to toggle source

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

@example Create a document in a different collection.

Model.with(collection: "secondary").create(name: "test")

@example Create a document in a different database.

Model.with(database: "secondary").create(name: "test")

@example Create a document in a different session.

Model.with(session: "secondary").create(name: "test")

@example Create with a combination of options.

Model.with(session: "sharded", database: "secondary").create

@param [ Hash ] options The storage options.

@option options [ String, Symbol ] :collection The collection name. @option options [ String, Symbol ] :database The database name. @option options [ String, Symbol ] :session The session name.

@return [ Class ] The model class.

@since 3.0.0

# File lib/mongoid/sessions/options.rb, line 135
def with(options)
  Proxy.new(self, (persistence_options || {}).merge(options))
end