Class: Mongoid::Config
- Includes:
- Singleton
- Defined in:
- lib/mongoid/config.rb
Overview
:nodoc
Instance Attribute Summary collapse
-
#allow_dynamic_fields ⇒ Object
Returns the value of attribute allow_dynamic_fields.
-
#raise_not_found_error ⇒ Object
Returns the value of attribute raise_not_found_error.
Instance Method Summary collapse
-
#database ⇒ Object
Returns the Mongo::DB to use or raise an error if none was set.
-
#database=(db) ⇒ Object
Sets the Mongo::DB to be used.
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
8 9 10 11 |
# File 'lib/mongoid/config.rb', line 8 def initialize @raise_not_found_error = true @allow_dynamic_fields = true end |
Instance Attribute Details
#allow_dynamic_fields ⇒ Object
Returns the value of attribute allow_dynamic_fields.
6 7 8 |
# File 'lib/mongoid/config.rb', line 6 def allow_dynamic_fields @allow_dynamic_fields end |
#raise_not_found_error ⇒ Object
Returns the value of attribute raise_not_found_error.
6 7 8 |
# File 'lib/mongoid/config.rb', line 6 def raise_not_found_error @raise_not_found_error end |
Instance Method Details
#database ⇒ Object
Returns the Mongo::DB to use or raise an error if none was set.
22 23 24 |
# File 'lib/mongoid/config.rb', line 22 def database @database || (raise Errors::InvalidDatabase.new("No database has been set, please use Mongoid.database=")) end |
#database=(db) ⇒ Object
Sets the Mongo::DB to be used.
14 15 16 17 18 19 |
# File 'lib/mongoid/config.rb', line 14 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 |