aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/application.erl
diff options
context:
space:
mode:
authorserge <[email protected]>2013-01-10 09:07:38 -0500
committerSerge Aleynikov <[email protected]>2013-01-14 13:24:41 -0500
commitd1d834820ddaba4fa31e6ab6d07a96ac7cc6d999 (patch)
tree9dd256e5390bc9845cfd1ccb094845a904bbb911 /lib/kernel/src/application.erl
parent9f461fbaf0be7aba7c0b8b89be1f0b6f1141b7a5 (diff)
downloadotp-d1d834820ddaba4fa31e6ab6d07a96ac7cc6d999.tar.gz
otp-d1d834820ddaba4fa31e6ab6d07a96ac7cc6d999.tar.bz2
otp-d1d834820ddaba4fa31e6ab6d07a96ac7cc6d999.zip
Add application:get_key/3
The new function provides a default value for a configuration parameter.
Diffstat (limited to 'lib/kernel/src/application.erl')
-rw-r--r--lib/kernel/src/application.erl16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/kernel/src/application.erl b/lib/kernel/src/application.erl
index 9b7c4aa7b8..4e65883be7 100644
--- a/lib/kernel/src/application.erl
+++ b/lib/kernel/src/application.erl
@@ -23,7 +23,7 @@
which_applications/0, which_applications/1,
loaded_applications/0, permit/2]).
-export([set_env/3, set_env/4, unset_env/2, unset_env/3]).
--export([get_env/1, get_env/2, get_all_env/0, get_all_env/1]).
+-export([get_env/1, get_env/2, get_env/3, get_all_env/0, get_all_env/1]).
-export([get_key/1, get_key/2, get_all_key/0, get_all_key/1]).
-export([get_application/0, get_application/1, info/0]).
-export([start_type/0]).
@@ -264,6 +264,20 @@ get_env(Key) ->
get_env(Application, Key) ->
application_controller:get_env(Application, Key).
+-spec get_env(Application, Par, Def) -> Val when
+ Application :: atom(),
+ Par :: atom(),
+ Def :: term(),
+ Val :: term().
+
+get_env(Application, Key, Def) ->
+ case get_env(Application, Key) of
+ {ok, Val} ->
+ Val;
+ undefined ->
+ Def
+ end.
+
-spec get_all_env() -> Env when
Env :: [{Par :: atom(), Val :: term()}].