Sha256: 00e66a7b0cde2a0f267faaf743dd71a02ca2f5b3fb4bba67c41aa31159bb9e3c

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 Bytes

Contents

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

    attr_accessor \
      :allow_dynamic_fields,
      :persist_in_safe_mode,
      :raise_not_found_error

    # Defaults the configuration options to true.
    def initialize
      @allow_dynamic_fields = true
      @persist_in_safe_mode = true
      @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

4 entries across 4 versions & 1 rubygems

Version Path
mongoid-1.1.4 lib/mongoid/config.rb
mongoid-1.1.3 lib/mongoid/config.rb
mongoid-1.1.2 lib/mongoid/config.rb
mongoid-1.1.1 lib/mongoid/config.rb