develooper Front page | perl.moose | Postings from June 2010

CGI::Application, MooseX::Decare and Roles

Thread Next
From:
Dan Horne
Date:
June 8, 2010 16:43
Subject:
CGI::Application, MooseX::Decare and Roles
Message ID:
AANLkTinXQOcVCjsaIawHmjb2NdN_ip1rqp8Sx2JA7gX0@mail.gmail.com
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:

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

Dan


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About