Class: MongoFe::MongoDB::Database
- Inherits:
-
Object
- Object
- MongoFe::MongoDB::Database
- Defined in:
- lib/mongo_fe.rb
Overview
simple proxy to Mongo::DB
Instance Method Summary collapse
- #find_user(username = nil) ⇒ Object
-
#initialize(db) ⇒ Database
constructor
A new instance of Database.
- #users ⇒ Object
Constructor Details
#initialize(db) ⇒ Database
Returns a new instance of Database.
16 17 18 |
# File 'lib/mongo_fe.rb', line 16 def initialize(db) @db=db end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
35 36 37 |
# File 'lib/mongo_fe.rb', line 35 def method_missing(name, *args, &block) @db.send(name, *args, &block) end |
Instance Method Details
#find_user(username = nil) ⇒ Object
26 27 28 29 30 |
# File 'lib/mongo_fe.rb', line 26 def find_user(username=nil) if db_users = @db[Mongo::DB::SYSTEM_USER_COLLECTION] db_users.find_one({:user => username}) unless username.nil? end end |
#users ⇒ Object
20 21 22 23 24 |
# File 'lib/mongo_fe.rb', line 20 def users if db_users = @db[Mongo::DB::SYSTEM_USER_COLLECTION] db_users.find.to_a end end |