Omnia illa, Quae Exspectant

Or to put in other words if you hang around long enough things will change. Well I actually did not have to wait very long at all about a month only. You may remember this post where I was recursively digging in to a directory of code to pre-load a number of Moose classes.

Well I had a solution to fix this problem

Can't locate object method "new_object" via package "Moose::Meta::Role" at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Moose/ line 27.

when I was trying to invoke 'new' on a role. My rather quick and dirty solution;

		unless($a_class->can('blessed') and $a_class->can('new') );	

did generate a comment from both Toby and Brad Gilbert that it was not perhaps the most wise thing to do and I could not really argue with them as it was just a quick fix.

Well Moose has made me happy again as of Mid April Moose::Utils now has added a new function 'is_role'. So now my code looks like this;

		if (.Moose::Util::is_role($a_class));	

So that is now looking, I think, a little better than before. I am not going to bother checking if something is an 'object' or a 'class' as it is my dir so I am fairly certain that the files in there are all either Moose roles or classes.

So thanks whom ever came up with this as it does help me out somewhat. As well it really does pay to read Planet Moose as that is where I read about this gem.


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