Sha256: e1295c37172c9584289d18c3eed4e53cbb408fe7b1a5ec850c82243723b54613

Contents?: true

Size: 705 Bytes

Versions: 18

Compression:

Stored size: 705 Bytes

Contents

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

    attr_accessor :raise_not_found_error, :allow_dynamic_fields

    def initialize
      @raise_not_found_error = true
      @allow_dynamic_fields = 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

18 entries across 18 versions & 1 rubygems

Version Path
mongoid-1.1.0 lib/mongoid/config.rb
mongoid-1.0.6 lib/mongoid/config.rb
mongoid-1.0.5 lib/mongoid/config.rb
mongoid-1.0.4 lib/mongoid/config.rb
mongoid-1.0.3 lib/mongoid/config.rb
mongoid-1.0.2 lib/mongoid/config.rb
mongoid-1.0.1 lib/mongoid/config.rb
mongoid-1.0.0 lib/mongoid/config.rb
mongoid-0.12.0 lib/mongoid/config.rb
mongoid-0.11.9 lib/mongoid/config.rb
mongoid-0.11.8 lib/mongoid/config.rb
mongoid-0.11.7 lib/mongoid/config.rb
mongoid-0.11.6 lib/mongoid/config.rb
mongoid-0.11.5 lib/mongoid/config.rb
mongoid-0.11.4 lib/mongoid/config.rb
mongoid-0.11.3 lib/mongoid/config.rb
mongoid-0.11.2 lib/mongoid/config.rb
mongoid-0.11.1 lib/mongoid/config.rb