Sha256: b165bce4fc252690db1f118f640dbad6e74401344d4a0df7c8c3fceb33787761

Contents?: true

Size: 728 Bytes

Versions: 4

Compression:

Stored size: 728 Bytes

Contents

module Mongo
  class Lock
    module ClassConvenienceMethods

      def init_and_send key, options = {}, method, &block
        lock = Mongo::Lock.new(key, options)
        lock.send(method, &block)
        lock
      end

      def acquire key, options = {}, &block
        init_and_send key, options, :acquire, &block
      end

      def release key, options = {}
        init_and_send key, options, :release
      end

      def acquire! key, options = {}
        init_and_send key, options, :acquire!
      end

      def release! key, options = {}
        init_and_send key, options, :release!
      end

      def available? key, options = {}
        Mongo::Lock.new(key, options).available?
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongo-lock-1.2.0 lib/mongo-lock/class_convenience_methods.rb
mongo-lock-1.1.4 lib/mongo-lock/class_convenience_methods.rb
mongo-lock-1.1.3 lib/mongo-lock/class_convenience_methods.rb
mongo-lock-1.1.1 lib/mongo-lock/class_convenience_methods.rb