Sha256: 3a7ec400696bc838cd3a0b9c8feb8e8e5df62e9e7047f1c9f1c117e3d05f7cbb
Contents?: true
Size: 1.86 KB
Versions: 4
Compression:
Stored size: 1.86 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, :raise_not_found_error # Defaults the configuration options to true. def initialize @allow_dynamic_fields = true @parameterize_keys = true @persist_in_safe_mode = true @raise_not_found_error = true @reconnect_time = 3 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
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
mongoid-pre-2.0.0.pre | lib/mongoid/config.rb |
mongoid-1.2.6 | lib/mongoid/config.rb |
mongoid-1.2.5 | lib/mongoid/config.rb |
mongoid-1.2.4 | lib/mongoid/config.rb |