Module: Marloss::InstanceMethods

Defined in:
lib/marloss.rb

Instance Method Summary collapse

Instance Method Details

#marloss_locker(name) ⇒ Object



50
51
52
# File 'lib/marloss.rb', line 50

def marloss_locker(name)
  Locker.new(marloss_store, name)
end

#marloss_storeObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/marloss.rb', line 38

def marloss_store
  @marloss_store ||=begin
    table = marloss_options_hash[:table]
    hash_key = marloss_options_hash[:hash_key]
    options = marloss_options_hash.reject do |k, v|
      k == :table || k == :hash_key
    end

    Store.new(table, hash_key, options)
  end
end

#with_marloss_locker(name, opts = {}) {|locker| ... } ⇒ Object

Yields:

  • (locker)


54
55
56
57
58
59
60
61
62
# File 'lib/marloss.rb', line 54

def with_marloss_locker(name, opts = {})
  locker = marloss_locker(name)

  locker.wait_until_lock_obtained(opts)

  yield(locker)

  locker.release_lock
end