Class: Mongoid::Collections::Master

Inherits:
Object
  • Object
show all
Includes:
Retry
Defined in:
lib/mongoid/collections/master.rb

Overview

This class wraps the MongoDB master database.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Retry

#retry_on_connection_failure

Constructor Details

#initialize(master, name, options = {}) ⇒ Master

Create the new database writer. Will create a collection from the master database.

Examples:

Create a new wrapped master.

Master.new(db, "testing")

Parameters:

  • master (Mongo::DB)

    The master database.

  • name (String)

    The name of the database.

  • options (Hash) (defaults to: {})

    The collection options.

Options Hash (options):

  • :capped (true, false)

    If the collection is capped.

  • :size (Integer)

    The capped collection size.

  • :max (Integer)

    The maximum number of docs in the capped collection.



40
41
42
# File 'lib/mongoid/collections/master.rb', line 40

def initialize(master, name, options = {})
  @collection = master.create_collection(name, options)
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



9
10
11
# File 'lib/mongoid/collections/master.rb', line 9

def collection
  @collection
end