Sha256: 993cf1641fb3dc8e708758d0a7a3a4428bf969191d144e62e6d71c39fdbfaff0

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc
  class Config #:nodoc
    include Singleton

    attr_accessor :raise_not_found_error

    def initialize
      @raise_not_found_error = true
    end

    # Sets the Mongo::DB to be used.
    def database=(db)
      raise Errors::InvalidDatabase.new(
          "Database should be a Mongo::DB, not #{db.class.name}"
        ) unless db.kind_of?(Mongo::DB)
      @database = db
    end

    # Returns the Mongo::DB to use or raise an error if none was set.
    def database
      @database || (raise Errors::InvalidDatabase.new("No database has been set, please use Mongoid.database="))
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid-0.11.0 lib/mongoid/config.rb
mongoid-0.10.6 lib/mongoid/config.rb