Sha256: 49ce392ad8d13f8480acbff8c236709be6dc516563cc450e2182212fa3bd40af

Contents?: true

Size: 1.43 KB

Versions: 178

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Collections #:nodoc:

    # This class wraps the MongoDB master database.
    class Master
      include Mongoid::Collections::Retry

      attr_reader :collection

      # All read and write operations should delegate to the master connection.
      # These operations mimic the methods on a Mongo:Collection.
      #
      # @example Proxy the driver save.
      #   collection.save({ :name => "Al" })
      Operations::ALL.each do |name|
        class_eval <<-EOS, __FILE__, __LINE__
          def #{name}(*args)
            retry_on_connection_failure do
              collection.#{name}(*args)
            end
          end
        EOS
      end

      # Create the new database writer. Will create a collection from the
      # master database.
      #
      # @example Create a new wrapped master.
      #   Master.new(db, "testing")
      #
      # @param [ Mongo::DB ] master The master database.
      # @param [ String ] name The name of the database.
      # @param [ Hash ] options The collection options.
      #
      # @option options [ true, false ] :capped If the collection is capped.
      # @option options [ Integer ] :size The capped collection size.
      # @option options [ Integer ] :max The maximum number of docs in the
      #   capped collection.
      def initialize(master, name, options = {})
        @collection = master.create_collection(name, options)
      end
    end
  end
end

Version data entries

178 entries across 86 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/collections/master.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/collections/master.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/collections/master.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/collections/master.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/collections/master.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/collections/master.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/collections/master.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/collections/master.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/collections/master.rb
mongoid-2.8.1 lib/mongoid/collections/master.rb
mongoid-2.8.0 lib/mongoid/collections/master.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/collections/master.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/collections/master.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/collections/master.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/collections/master.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/collections/master.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/collections/master.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/collections/master.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/collections/master.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/collections/master.rb