Skip to content

Commit

Permalink
Improved documentaiton and internal callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Licenser committed Mar 15, 2013
1 parent cd1eeb1 commit 7f6e8ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions README.md
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions src/eplugin.erl
Expand Up @@ -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])
Expand All @@ -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.
Expand Down

0 comments on commit 7f6e8ff

Please sign in to comment.