Class: Munificent::Game

Inherits:
ApplicationRecord show all
Defined in:
app/models/munificent/game.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#to_s

Instance Method Details

#bulk_key_entryObject



10
# File 'app/models/munificent/game.rb', line 10

def bulk_key_entry; end

#bulk_key_entry=(codes) ⇒ Object



12
13
14
15
16
17
18
# File 'app/models/munificent/game.rb', line 12

def bulk_key_entry=(codes)
  requested_codes = codes.split("\n")
  existing_codes = keys.map(&:code)
  new_codes = (requested_codes - existing_codes).map { |code| Key.new(code:) }

  self.keys += new_codes
end