class Snapscatter::MongoLocker
Public Class Methods
new(spec)
click to toggle source
# File lib/snapscatter/locker.rb, line 32 def initialize spec @host = spec[:host] && spec.delete(:host) @port = spec[:port] && spec.delete(:port) user = spec[:usr] && spec.delete(:usr) password = spec[:pwd] && spec.delete(:pwd) if @host @client = Mongo::MongoClient.new @host, @port, spec # spec contains the options else @client = Mongo::MongoClient.new end if user @client.add_auth 'admin', user, password, nil end end
Public Instance Methods
lock()
click to toggle source
# File lib/snapscatter/locker.rb, line 49 def lock @client.lock! puts "locked mongo instance at #{@host}" end
unlock()
click to toggle source
# File lib/snapscatter/locker.rb, line 54 def unlock @client.unlock! puts "unlocked mongo instance at #{@host}" end