On Wed, Jun 09, 2010 at 11:43:33AM +1200, Dan Horne wrote:
> Hi
>
> I'm trying to figure out how to combine the combination of CGI::Application,
> MooseX::Decare and Roles in my CGI:App controller base class.A quick Google
> gave me the solution for using the first two at
> http://stackoverflow.com/questions/1060470/turning-off-inline-constructors-with-moosexdeclare/1061789#1061789:
You might also want to look at MooseX::NonMoose here - it would let you
keep immutability, and generally let you not have to think about these
types of things.
> use MooseX::Declare;
>
> class MyApp::CGI extends CGI::Application is mutable {
>
> around new {
> my $obj = $self->SUPER::new( @_ );
> return $self->meta->new_object( __INSTANCE__ => $obj, @_ );
> }
>
> method setup {
> $self->start_mode( 'main' );
>
> my @methods = map { $_->name } $self->meta->get_all_methods;
>
> $self->run_modes( map { /^rm_(.+)$/ => $_ }
> grep { /^rm_/ }
> @methods
> );
> }
>
> __PACKAGE__->meta->make_immutable( inline_constructor => 0 );
> }
>
> However, I want to add roles to my base class, but any sub-class blows up
> with: "The 'add_method' method cannot be called on an immutable instance."
>
> Suggestions to get around this are appreciated
This sounds like a bug in the 1.06 release - try 1.07 and see if that
fixes it.
-doy