Skip to content

Commit

Permalink
Fixed noreply typo. Added get/2, which is get/1 with default value.
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell committed Jan 4, 2012
1 parent b33d58f commit 2270746
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/support/z_config.erl
Expand Up @@ -35,6 +35,7 @@
% API export
-export([
get/1,
get/2,
set/2,
get_dirty/1,
set_dirty/2
Expand All @@ -56,6 +57,13 @@ start_link() ->
get(Key) ->
gen_server:call(?MODULE, {get, Key}).

%% @doc Get value from config file, returning default value when not set (cached)
get(Key, Default) ->
case gen_server:call(?MODULE, {get, Key}) of
undefined -> Default;
Value -> Value
end.

%% @doc Set value in config file, update cache.
set(Key, Value) ->
gen_server:cast(?MODULE, {set, Key, Value}).
Expand Down Expand Up @@ -145,7 +153,7 @@ handle_cast({set, Key, Value}, State) ->
{noreply, State};
_ ->
Config = write_config(Key, Value),
{no_reply, State#state{config=Config}}
{noreply, State#state{config=Config}}
end;

%% @doc Trap unknown casts
Expand Down

0 comments on commit 2270746

Please sign in to comment.