Class: Appshot::MongoDB
- Inherits:
-
Object
- Object
- Appshot::MongoDB
- Defined in:
- lib/appshot/app/mongodb.rb
Instance Method Summary collapse
- #call(call_chain) ⇒ Object
-
#initialize(opts = {}) ⇒ MongoDB
constructor
A new instance of MongoDB.
- #lock ⇒ Object
- #unlock ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ MongoDB
Returns a new instance of MongoDB.
4 5 6 7 |
# File 'lib/appshot/app/mongodb.rb', line 4 def initialize(opts={}) @port = opts[:port] || 27017 @mongo_binary = opts[:database_command] || "mongo" end |
Instance Method Details
#call(call_chain) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/appshot/app/mongodb.rb', line 9 def call(call_chain) next_action = call_chain.shift lock next_action.call(call_chain) unless next_action.nil? ensure unlock end |
#lock ⇒ Object
17 18 19 |
# File 'lib/appshot/app/mongodb.rb', line 17 def lock %x[#{@mongo_binary} --host localhost:#{@port} --eval "db.fsyncLock()"] end |
#unlock ⇒ Object
21 22 23 |
# File 'lib/appshot/app/mongodb.rb', line 21 def unlock %x[#{@mongo_binary} --host localhost:#{@port} --eval "db.fsyncUnlock()"] end |