Skip to content

MishaConway/elixir-attribute-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

genserver for globally storing attributes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages