Sha256: 1e1e8d085caa3824fbc0e58d1190d8e756fa26457321f5cb93e8a64c0fb713bb
Contents?: true
Size: 1.96 KB
Versions: 9
Compression:
Stored size: 1.96 KB
Contents
# encoding: utf-8 module Mongoid #:nodoc class Config #:nodoc include Singleton attr_accessor \ :allow_dynamic_fields, :reconnect_time, :parameterize_keys, :persist_in_safe_mode, :persist_types, :raise_not_found_error, :use_object_ids # Defaults the configuration options to true. def initialize @allow_dynamic_fields = true @parameterize_keys = true @persist_in_safe_mode = true @persist_types = true @raise_not_found_error = true @reconnect_time = 3 @use_object_ids = false end # Sets the Mongo::DB master database to be used. If the object trying to me # set is not a valid +Mongo::DB+, then an error will be raise. # # Example: # # <tt>Config.master = Mongo::Connection.db("test")</tt> # # Returns: # # The Master DB instance. def master=(db) raise Errors::InvalidDatabase.new(db) unless db.kind_of?(Mongo::DB) @master = db end # Returns the master database, or if none has been set it will raise an # error. # # Example: # # <tt>Config.master</tt> # # Returns: # # The master +Mongo::DB+ def master @master || (raise Errors::InvalidDatabase.new(nil)) end alias :database :master alias :database= :master= # Sets the Mongo::DB slave databases to be used. If the objects trying to me # set are not valid +Mongo::DBs+, then an error will be raise. # # Example: # # <tt>Config.slaves = [ Mongo::Connection.db("test") ]</tt> # # Returns: # # The slaves DB instances. def slaves=(dbs) dbs.each { |db| raise Errors::InvalidDatabase.new(db) unless db.kind_of?(Mongo::DB) } @slaves = dbs end # Returns the slave databases, or if none has been set nil # # Example: # # <tt>Config.slaves</tt> # # Returns: # # The slave +Mongo::DBs+ def slaves @slaves end end end
Version data entries
9 entries across 9 versions & 2 rubygems