diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-01-23 10:54:52 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-01-23 10:54:52 +0300 |
commit | ba2b650464bd3aae2b6b0f3a3177476360cb6d08 (patch) | |
tree | 5d55501f76edcdcfe145ba0c3367a54ea0314e5c /src/mod_time.erl | |
parent | Do not try to start ezlib application too frequently (diff) |
Introduce new gen_mod callback: mod_options/1
The callback is supposed to provide known options and their default
values, as long as the documentation. Passing default values into
get_mod functions is now deprecated: all defaults should be provided
by the Mod:mod_options/1 callback.
Diffstat (limited to 'src/mod_time.erl')
-rw-r--r-- | src/mod_time.erl | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mod_time.erl b/src/mod_time.erl index 4b3b67c9..d4dffbf1 100644 --- a/src/mod_time.erl +++ b/src/mod_time.erl @@ -33,7 +33,7 @@ -behaviour(gen_mod). -export([start/2, stop/1, reload/3, process_local_iq/1, - mod_opt_type/1, depends/2]). + mod_opt_type/1, mod_options/1, depends/2]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -41,7 +41,7 @@ -include("xmpp.hrl"). start(Host, Opts) -> - IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)), + IQDisc = gen_mod:get_opt(iqdisc, Opts), gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_TIME, ?MODULE, process_local_iq, IQDisc). @@ -50,7 +50,7 @@ stop(Host) -> ?NS_TIME). reload(Host, NewOpts, OldOpts) -> - case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of + case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts) of {false, IQDisc, _} -> gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_TIME, ?MODULE, process_local_iq, IQDisc); @@ -74,5 +74,7 @@ process_local_iq(#iq{type = get} = IQ) -> depends(_Host, _Opts) -> []. -mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1; -mod_opt_type(_) -> [iqdisc]. +mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1. + +mod_options(Host) -> + [{iqdisc, gen_iq_handler:iqdisc(Host)}]. |