Class: MongoBrowser::Models::Database
- Inherits:
-
Object
- Object
- MongoBrowser::Models::Database
- Defined in:
- lib/mongo_browser/models/database.rb
Instance Attribute Summary collapse
-
#mongo_db ⇒ Object
readonly
Returns the value of attribute mongo_db.
Instance Method Summary collapse
- #collection(name) ⇒ Object
- #collection_names ⇒ Object
- #collections ⇒ Object
- #count ⇒ Object
- #drop! ⇒ Object
-
#initialize(mongo_db) ⇒ Database
constructor
A new instance of Database.
- #name ⇒ Object (also: #id)
- #size ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(mongo_db) ⇒ Database
Returns a new instance of Database.
6 7 8 |
# File 'lib/mongo_browser/models/database.rb', line 6 def initialize(mongo_db) @mongo_db = mongo_db end |
Instance Attribute Details
#mongo_db ⇒ Object (readonly)
Returns the value of attribute mongo_db.
4 5 6 |
# File 'lib/mongo_browser/models/database.rb', line 4 def mongo_db @mongo_db end |
Instance Method Details
#collection(name) ⇒ Object
27 28 29 |
# File 'lib/mongo_browser/models/database.rb', line 27 def collection(name) Collection.new(mongo_db.collection(name)) end |
#collection_names ⇒ Object
23 24 25 |
# File 'lib/mongo_browser/models/database.rb', line 23 def collection_names mongo_db.collection_names end |
#collections ⇒ Object
31 32 33 |
# File 'lib/mongo_browser/models/database.rb', line 31 def collections collection_names.map { |name| collection(name) } end |
#count ⇒ Object
15 16 17 |
# File 'lib/mongo_browser/models/database.rb', line 15 def count collections.count end |
#drop! ⇒ Object
39 40 41 |
# File 'lib/mongo_browser/models/database.rb', line 39 def drop! mongo_db.connection.drop_database(self.name) end |
#name ⇒ Object Also known as: id
10 11 12 |
# File 'lib/mongo_browser/models/database.rb', line 10 def name mongo_db.name end |
#size ⇒ Object
19 20 21 |
# File 'lib/mongo_browser/models/database.rb', line 19 def size info["sizeOnDisk"].to_i end |
#stats ⇒ Object
35 36 37 |
# File 'lib/mongo_browser/models/database.rb', line 35 def stats mongo_db.stats end |