Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Add couch_epi:is_configured
  • Loading branch information
iilyak committed Jul 29, 2015
1 parent fe02b29 commit a57fc94efc8c2e98cbb41174c52e02460416c783
Showing 2 changed files with 16 additions and 1 deletion.
@@ -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).
@@ -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()),

0 comments on commit a57fc94

Please sign in to comment.