Class: Munificent::KeyAssignment::KeyManager

Inherits:
Object
  • Object
show all
Defined in:
app/services/munificent/key_assignment/key_manager.rb

Instance Method Summary collapse

Instance Method Details

#key_assigned?(game, donator_bundle_tier:) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'app/services/munificent/key_assignment/key_manager.rb', line 4

def key_assigned?(game, donator_bundle_tier:)
  donator_bundle_tier.assigned_games.include?(game)
end

#lock_unassigned_key(game, fundraiser: nil) ⇒ Object



8
9
10
11
12
13
14
# File 'app/services/munificent/key_assignment/key_manager.rb', line 8

def lock_unassigned_key(game, fundraiser: nil)
  # https://api.rubyonrails.org/v6.1.0/classes/ActiveRecord/Locking/Pessimistic.html
  # https://www.postgresql.org/docs/9.5/sql-select.html#SQL-FOR-UPDATE-SHARE
  Munificent::Key.transaction do
    yield unassigned_key(game, fundraiser:)
  end
end