genserver for globally storing attributes
This code is available in Hex at (https://hex.pm/packages/attribute_server) and can be installed as:
- Add
attribute_serverto your list of dependencies inmix.exs:
```elixir
def deps do
[{:attribute_server, "~> 0.1.0"}]
end
```
Use it in a module you want to track attributes in
defmodule MyApp.GameState do
...
use AttributeServer
...
end set
# set some attributes
MyApp.GameState.set :current_score, 1000
MyApp.GameState.set :current_level, 3get
# get some attributes
MyApp.GameState.get :current_score
MyApp.GameState.get :current_levelall
# retrieve all attributes
MyApp.GameState.allclear
# clear all attributes
MyApp.GameState.clearsize
# get total number of attributes
MyApp.GameState.size