Repository: couchdb-couch-epi Updated Branches: refs/heads/master fe02b2971 -> a57fc94ef
Add couch_epi:is_configured Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-epi/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-epi/commit/a57fc94e Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-epi/tree/a57fc94e Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-epi/diff/a57fc94e Branch: refs/heads/master Commit: a57fc94efc8c2e98cbb41174c52e02460416c783 Parents: fe02b29 Author: ILYA Khlopotov <[email protected]> Authored: Fri Jun 26 11:47:38 2015 -0700 Committer: ILYA Khlopotov <[email protected]> Committed: Wed Jul 29 08:33:22 2015 -0700 ---------------------------------------------------------------------- src/couch_epi.erl | 8 ++++++++ src/couch_epi_functions_gen.erl | 9 ++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-epi/blob/a57fc94e/src/couch_epi.erl ---------------------------------------------------------------------- diff --git a/src/couch_epi.erl b/src/couch_epi.erl index 8787c88..417b3fc 100644 --- a/src/couch_epi.erl +++ b/src/couch_epi.erl @@ -25,6 +25,8 @@ -export([apply/5]). -export([any/5, all/5]). +-export([is_configured/3]). + -export_type([service_id/0, app/0, key/0, handle/0, notify_cb/0]). -type app() :: atom(). @@ -156,3 +158,9 @@ any(Handle, ServiceId, Function, Args, Opts) -> all(Handle, ServiceId, Function, Args, Opts) -> Replies = apply(Handle, ServiceId, Function, Args, Opts), [] == [Reply || Reply <- Replies, Reply == false]. + +-spec is_configured( + Handle :: handle(), Function :: atom(), Arity :: pos_integer()) -> boolean(). + +is_configured(Handle, Function, Arity) -> + [] /= couch_epi_functions_gen:modules(Handle, Function, Arity). http://git-wip-us.apache.org/repos/asf/couchdb-couch-epi/blob/a57fc94e/src/couch_epi_functions_gen.erl ---------------------------------------------------------------------- diff --git a/src/couch_epi_functions_gen.erl b/src/couch_epi_functions_gen.erl index a08573c..6d93787 100644 --- a/src/couch_epi_functions_gen.erl +++ b/src/couch_epi_functions_gen.erl @@ -12,7 +12,7 @@ -module(couch_epi_functions_gen). --export([add/3, remove/3, get_handle/1, hash/1, apply/4, apply/5]). +-export([add/3, remove/3, get_handle/1, hash/1, apply/4, apply/5, modules/3]). -export([save/3]). @@ -311,6 +311,11 @@ remove_from_definitions(Defs, Source) -> {[], Defs} end. +-spec modules(Handle :: atom(), Function :: atom(), Arity :: pos_integer()) -> + list(). +modules(Handle, Function, Arity) -> + providers(Handle, Function, Arity, #opts{ignore_providers = true}). + %% ------------------------------------------------------------------ %% Tests %% ------------------------------------------------------------------ @@ -328,6 +333,8 @@ basic_test() -> Module = foo_bar_dispatcher, add(Module, app1, [?MODULE]), + ?assertMatch([?MODULE], modules(Module, foo, 2)), + ?assert(is_list(Module:version(app1))), Defs1 = lists:usort(Module:definitions()),
