On Sat, 15 Dec 2012 12:35:15 -0500
David Golden <[email protected]> wrote:
> On Sat, Dec 15, 2012 at 11:40 AM, David Precious
> <[email protected]> wrote:
> > And to require specific roles:
> >
> > get '/beer' => requires_role BeerDrinker => sub { ... };
>
> As implemented, requires_role() only allows a single role. I think
> you should do something along the lines of:
>
> sub requires_role {
> my $coderef = pop;
> my @roles = @_;
> ...
> }
>
> And then s/requires_role/requires_roles/ perhaps.
Yeah, that's true. I was thinking that require_role could accept an
arrayref of roles instead of a straightforward role, if desired, so you
could also say e.g.:
get '/foo' => requires_role ['Foo','Bar'] => sub { ... };
(requires_roles could be added as an alias, so code could read better.)
I imagine the common requirement will be to say "any of these roles",
not "all of these roles". I was considering whether requires_role
should be for "must have this role" or "must have all of these roles",
and e.g. a new requires_any_role keyword would be added to ensure a
user had all the specified roles; I'm not sure how valuable that would
be, though.
--
David Precious ("bigpresh") <[email protected]>
http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan www.preshweb.co.uk/github
_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users