Add cfg/1 to Omnibot.Plugin macro
This allows getting a specific key from the configuration instead of
getting the full array. Allows for using this:
cfg(:some_config)
instead of this:
cfg()[:some_config]
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -37,6 +37,10 @@ defmodule Omnibot.Plugin do
|
|||||||
Omnibot.Plugin.CfgState.cfg(__MODULE__.CfgState)
|
Omnibot.Plugin.CfgState.cfg(__MODULE__.CfgState)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cfg(opt, default \\ nil) when unquote(opts[:include_base]) do
|
||||||
|
Keyword.get(cfg(), opt, default)
|
||||||
|
end
|
||||||
|
|
||||||
def state() when unquote(opts[:include_base]) do
|
def state() when unquote(opts[:include_base]) do
|
||||||
Omnibot.Plugin.CfgState.state(__MODULE__.CfgState)
|
Omnibot.Plugin.CfgState.state(__MODULE__.CfgState)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user