class Game::PersistentStore
Public Class Methods
Source
# File lib/game_persistent_store.rb, line 10 def initialize(plugin:, key:, symbolize_loaded_hashes: false) @plugin = plugin @key = key @symbolize_loaded_hashes = symbolize_loaded_hashes @data = nil end
Public Instance Methods
Source
# File lib/game_persistent_store.rb, line 17 def [](storage_key) data[storage_key.to_s] end
Source
# File lib/game_persistent_store.rb, line 21 def []=(storage_key, value) data[storage_key.to_s] = value persist! value end
Source
# File lib/game_persistent_store.rb, line 34 def delete(storage_key) removed = data.delete(storage_key.to_s) persist! removed end
Source
# File lib/game_persistent_store.rb, line 44 def each(&block) data.each(&block) end
Source
# File lib/game_persistent_store.rb, line 27 def fetch(storage_key, default = nil) string_key = storage_key.to_s return data[string_key] if data.key?(string_key) default.is_a?(Proc) ? default.call : default end
Source
# File lib/game_persistent_store.rb, line 40 def key?(storage_key) data.key?(storage_key.to_s) end