New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve support for "has" in Dancer2::Plugin #1292
Improve support for "has" in Dancer2::Plugin #1292
Conversation
This should work now: has [qw(field1 field2)] => ( is => 'ro', from_config => 1, plugin_keyword => 1, );
FWIW, there's weirdness with from_config and plugin_keyword with non-1 values. IE: has [qw(foo bar)] => (
is => 'ro',
from_config => 'foo',
plugin_keyword => [qw(foo bar)],
); Both "foo" and "bar" will use the key "foo" for their default value, which is probably OK... but the keywords "foo" and "bar" will both use the "bar" attribute, which is unintuitive. I was thinking of maybe adding a warning to Dancer2::Plugin::p2_has_keyword if $class->keywords->{$} already exists, or a warning in the documentation. What do you guys think? |
👍 |
Hello again! Just pinging. Is there anything else you'd like me to do, or is this good? |
No. It's good. We just need a bit of time. The Advent Calendar is starting tomorrow so we've been pressed for time. |
As for your question, I think we should not allow defining two attributes at the same time with two plugin keywords attribute. There can be different conditions checked here, but I think the simplest one would be "If you're defining an attribute with an array, you cannot provide a |
3344b59
to
d33d7d4
Compare
Cool! I've added that check and a quick unit test (shoe-horned into from-config.t). |
Looks good to me 👍 Sorry its taken soooooo long to look over it :( |
Cherry-picked onto current master and merged. @nfg++ Apologies again for it taking soooo long. |
No worries. Thanks, eh! |
[ BUG FIXES ] * GH #1090, #1406: Replace HTTP::Body with HTTP::Entity::Parser in Dancer2::Core::Request. (Russell @veryrusty Jenkins) * GH #1292: Fix multiple attribute definitions within Plugins (Nigel Gregoire) * GH #1304: Fix the order by which config files are loaded, independently of their filename extension (Alberto Simões, Russell @veryrusty Jenkins) * GH #1400: Fix infinite recursion with exceptions that use circular references. (Andre Walker) * GH #1430: Fix `dancer2 gen` from source directory when Dancer2 not installed. (Tina @perlpunk Müller - Tina) * GH #1434: Add `validate_id` method to verify a session id before requesting the session engine fetch it from its data store. (Russell @veryrusty Jenkins) * GH #1435, #1438: Allow XS crush_cookie methods to return an arrayref of values. (Russell @veryrusty Jenkins) * GH #1443: Update copyright year (Joseph Frazer) * GH #1445: Use latest HTTP::Headers::Fast (Russell @veryrusty Jenkins) * PR #1447: Fix missing build requires (Mohammad S Anwar) [ ENHANCEMENTS ] * PR #1354: TemplateToolkit template engine will log (at debug level) if a template is not found. (Kiel R Stirling, Russell @veryrusty Jenkins) * GH #1432: Support Content-Disposition of inline in send_file() (Dave Webb) * PR #1433: Verbose testing in AppVeyor (Graham Knop) [ DOCUMENTATION ] * GH #1314: Documentation tweaks (David Precious) * GH #1317: Document serializer configuration (sdeseille) * GH #1386: Add Hello World example (Gabor Szabo) * PR #1408: List project development resources (Steve Dondley) * PR #1426: Move performance improvement information from Migration guide to Deployment (Pedro Melo)
Hello! I was writing a Dancer2 plugin for $WORK, and couldn't figure out why my attributes weren't pulling their values from the plugin configs. Eventually I figured out it was because I was defining multiple attributes at once in my plugin, a la:
When I run that script and hit localhost:3000/ , I get:
This PR should fix the issue.