MooseX::AuthorizedMethodRole - Syntax sugar for authorized methods by MooseX::Role
package Foo::Bar; use MooseX::AuthorizedMethodRoles; # includes Moose with ('Role::Bill::Bloggins', 'Role::Blog::Save', 'Role::One::Two'); authorized_roles foo => {one_of=>['Role::Bill::Bloggins','Role::Bilbo::Baggings']} sub { # this is going to happen only if the package impliments role # 'Role::Bill::Bloggins' or 'Role::Bilbo::Baggings' or both. }; authorized_roles bar => {required=>['Role::Blog::Save']} sub { # this is going to happen only if the package impliments role # 'Role::Blog::Save'. };
This method exports the "authorized_role" declarator that makes a verification that the present package expresses the Moose::Roles as describebe by the API. So far the API has two rules 'one_of', meaning the package must express at least one of listed the Moose::Roles and 'required' meaning is must express all of the listed Moose::Roles.
This declarator requres that you use at least one of the API keys, It checks the current package's Roles and dies if the condtions are not met.
The curent API allows for two keywords, these keywords must be followed by an Array-Ref of Moose::Roles.
This keyword means the the current package must have at least one of the roles in the Array-Ref it points to. As soon as it finds one it returns true and fires the code otherwise it will die.
This keyword means the the current package must have all of the roles in the Array-Ref it points to. It will iterate over the list and die if as soon as one Moose::Role is not expressed.
You can use both keywords at the same time so this
authorized_roles bar => {one_of=>['Role::Bill::Bloggins','Role::Bilbo::Baggings']} required=>['Role::Blog::Save']} sub { ... };
is allowed. It this type of configuation both the 'one_of' and 'required' must pass if the code is going to fire.
package Product::Order; use Moose; ... authorized_roles shipping_authorized => {one_of=>[qw (Product::BRULE::PO Product::BRULE::Standing_Offer Product::BRULE::Paid_In_Full)]} , sub { ... }; authorized_roles bill_after_30_days => {requied=>[qw (Product::BRULE::PO)]} , sub { ... }; package Standing::Order; use Moose; extends 'Product::Order'; with 'Product::BRULE::Standing_Offer'; ...
The package Standing::Order can invoke 'shipping_authorized' but it cannot invoke 'bill_after_30_days'
Nothing special just use CPAN or if you want just follow the below.
Dowload and unzip the tar file and then to install this module, run the following commands:
perl Makefile.PL make make test make install
L<https://metacpan.org/pod/MooseX::Meta::Method::Authorized/> for the insparation for this MooseX
John Scoles, <byterock at hotmail.com>
<byterock at hotmail.com>
Please report any bugs or feature requests through the web interface at https://github.com/byterock/Moosex-AuthorizedMethodRoles/issues.
You can find documentation for this module with the perldoc command. perldoc MooseX::AuthorizedMethodRoles You can also look for information at:
AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/MooseX-AuthorizedMethodRoles/
CPAN Ratings http://cpanratings.perl.org/d/MooseX-AuthorizedMethodRoles/
Search CPAN http://search.cpan.org/dist/MooseX-AuthorizedMethodRoles/
Daniel Ruoso (l<https://metacpan.org/author/DRUOSO/>)
- For 'https://metacpan.org/pod/MooseX::Meta::Method::Authorized/' which I used completly wrong to start then had to scramble to create this one to cover my tracks
<a href="https://github.com/byterock/Moosex-AuthorizedMethodRoles">
Copyright 2014 by John Scoles
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MooseX::AuthorizedMethodRoles, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::AuthorizedMethodRoles
CPAN shell
perl -MCPAN -e shell install MooseX::AuthorizedMethodRoles
For more information on module installation, please visit the detailed CPAN module installation guide.