Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 977 Bytes

README.md

File metadata and controls

61 lines (47 loc) · 977 Bytes

AttributeServer

genserver for globally storing attributes

Installation

This code is available in Hex at (https://hex.pm/packages/attribute_server) and can be installed as:

  1. Add attribute_server to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:attribute_server, "~> 0.1.0"}]
end
```

Configuration

Use it in a module you want to track attributes in

defmodule MyApp.GameState do
  ...
  use AttributeServer
  ...
end  

Usage

set

    # set some attributes
	   MyApp.GameState.set :current_score, 1000
     MyApp.GameState.set :current_level, 3

get

    # get some attributes
	   MyApp.GameState.get :current_score
     MyApp.GameState.get :current_level

all

  # retrieve all attributes
	MyApp.GameState.all

clear

  # clear all attributes
	MyApp.GameState.clear

size

  # get total number of attributes
	MyApp.GameState.size