Permalink
Browse files

Fixed noreply typo. Added get/2, which is get/1 with default value.

  • Loading branch information...
1 parent b33d58f commit 2270746a3d2b094389ab0c29aed631eb48d050c5 @mworrell mworrell committed Jan 4, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/support/z_config.erl
View
@@ -35,6 +35,7 @@
% API export
-export([
get/1,
+ get/2,
set/2,
get_dirty/1,
set_dirty/2
@@ -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}).
@@ -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

0 comments on commit 2270746

Please sign in to comment.