%%%------------------------------------------------------------------- %%% @author dn290597jan %%% @copyright (C) 2016, %%% @doc %%% %%% @end %%% Created : 27. Apr 2016 13:48 %%%------------------------------------------------------------------- -module(application_settings). -author("dn290597jan"). %% API -export([get_section_settings/2]). get_section_settings(Application,Key) -> case os:getenv("ERLANG_ENV") of "Prod" -> case get_section_with_suffix(Application,Key,"_prod") of undefined -> application:get_env(Application, list_to_atom(Key)); Ather -> Ather end; % env var not defined "Stage" -> case get_section_with_suffix(Application,Key,"_stage") of undefined -> application:get_env(Application, list_to_atom(Key)); Ather -> Ather end; % env var not defined _ -> application:get_env(Application,list_to_atom(Key)) end. get_section_with_suffix(Application,Key,Suffix)-> NewKey = list_to_atom(string:join([Key,Suffix],"")), application:get_env(Application, NewKey).