class MemoryRepository class << self def boards @boards ||= {} end end def boards self.class.boards end def create(id:) boards[id] = { player: :player_1, board: [ [:free, :free, :free], [:free, :free, :free], [:free, :free, :free], ], } end def find(id) data = boards.fetch id TicTacToe::Game.new( id: id, repository: self, player: data[:player], board: data[:board].dup, ) end def store(game) boards[game.id] = { player: game.player, board: game.board.dup, } end end