Permalink
Browse files

Improved documentaiton and internal callbacks.

  • Loading branch information...
1 parent cd1eeb1 commit 7f6e8ff6945387df0b7baa192468504c81d8f490 @Licenser committed Mar 15, 2013
Showing with 14 additions and 3 deletions.
  1. +12 −3 README.md
  2. +2 −0 src/eplugin.erl
View
@@ -78,7 +78,16 @@ The option disabled in the OptionPlist will disable the plugin at load time.
Callbacks
=========
+
+notation
+--------
+callbacks are noted as `<callback name>(arguments)` so `eplugin:init(Config)` means the callback `eplugin:init` is caled with 1 argument - `Config`.
+
+internal callbacks
+------------------
eplugin provides the following callbacks itself:
-* eplugin:init - this is called when all modules are compiled. The Plugins config is passed.
-* eplugin:enable - this is called before a module gets enabled. The Plugins config is passed.
-* eplugin:disable - this gets called after a module gets disabled. The Plugins config is passed.
+* eplugin:init(Config) - this is called when all modules are compiled.
+* eplugin:enable(Config) - this is called before a module gets enabled.
+* eplugin:disable(Config) - this gets called after a module gets disabled.
+* eplugin:enable_plugin(Plugin) - this gets called whenever a plugin is enabled.
+* eplugin:disable_plugin(Plugin) - this gets called whenever a plugin is disabled.
View
@@ -153,6 +153,7 @@ disable(Plugin) ->
ets:match_delete(?TABLE, {'_', Plugin, '_', '_'}),
{ok, Config} = config(Plugin),
[erlang:apply(M, F, [Config]) || [M, F] <- Callback],
+ eplugin:apply('eplugin:disable_plugin', [Plugin]),
ok;
false ->
lager:warning("[eplugin::~p] already disabled.", [Plugin])
@@ -176,6 +177,7 @@ enable(Plugin) ->
end, Callbacks)
end, Modules),
[register_callbacks(Plugin, M) || M <- Modules],
+ eplugin:apply('eplugin:enable_plugin', [Plugin]),
ok
end
end.

0 comments on commit 7f6e8ff

Please sign in to comment.