On the Correct Path Again

Well back to Perl posting today. You might remember a very bad thing I did in my last post namely altering an installed module and thus breaking any chance of portability or at least maintainability of my current project.

Well the old story of short term expedience for long term failure is fine for the next few days but I really do need a better solution so in the end I will have to write some of my own code.

Well I was thinking of just writing a different version of 'MooseX-AuthorizedMethods' unfortunately this was not as easy as I first thought. Seems the above Mod the way it was designed sort of hogs the 'Method::Authorized' namespace as I do not see anyway I could add my own 'Method::Authorized' package without either clobbering the original or rewriting it to be more namespace friendly.

So what to do??

Well it looks like I have to come up with my own namespace and this does require a little though and it is always good to get a little feedback when choosing a namespace. So I popped a few ideas past a friend or two.

The best choice it to pick something that 'Describes' what I am attempting to do. In this case I am

Only allowing an class instance that had one or more roles to invoke a method

So after a little debate we came up with 'authorized_roles', some of the debating points where

We just can't use 'authorized' as that is already taken
'only_roles' sort of implies that the method set the roles
There are some 'sugar' declarators that use hyphens
We need to get the idea across this is moose 'Role' bases

So the name space is sort of stubbed in as


and used something like the original

package Foo::Bar;
use MooseX::AuthorizedMethodRoles;

has user => (is => 'ro');

authorized_roles foo => ['foo'], sub {

Now just to write up the code for this and I am done.


Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations