Dancer::Plugin internal sharing
I've been creating quite a few Dancer plugins recently. The nice part of a Dancer plugin is that it gives a small new set of keywords.
In some cases, I've want to provide a generic keyword interface to an object but then provide smarter business level keywords. I've found a quirk in the Dancer::Plugin interface. I couldn't find it documented anywhere but I'm sure it is.
If you want to access keywords from the same space that they are registered you need to use a different format than the:
You need to use the pattern:
register_plugin actually stuffs the symbols into the namespace therefore you need to share the sub names before that happens to use them.
In some cases, I've want to provide a generic keyword interface to an object but then provide smarter business level keywords. I've found a quirk in the Dancer::Plugin interface. I couldn't find it documented anywhere but I'm sure it is.
If you want to access keywords from the same space that they are registered you need to use a different format than the:
register keyword => sub {};
You need to use the pattern:
sub keyword { # do stuff } register keyword => \&keyword;
register_plugin actually stuffs the symbols into the namespace therefore you need to share the sub names before that happens to use them.
Comments
Post a Comment