X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flib%2FTestApp%2FController%2FMoose.pm;h=705b2bd9bccf892650c701d36091d7344370376c;hp=578368601617ba8f48d57fc1eb9f743e6faac28d;hb=82010ea176741c7a4f2baf3f6f27377b1d9f6b15;hpb=f04fdedae056296d0fa97fbdcaa85b9811ca6a5b diff --git a/t/lib/TestApp/Controller/Moose.pm b/t/lib/TestApp/Controller/Moose.pm index 5783686..705b2bd 100644 --- a/t/lib/TestApp/Controller/Moose.pm +++ b/t/lib/TestApp/Controller/Moose.pm @@ -2,40 +2,32 @@ package TestApp::Controller::Moose; use Moose; +use namespace::clean -except => 'meta'; + BEGIN { extends qw/Catalyst::Controller/; } +use MooseX::MethodAttributes; # FIXME - You need to say this if you have + # modifiers so that you get the correct + # method metaclass, why does the modifier + # on MODIFY_CODE_ATTRIBUTES not work. -has attribute => ( # Test defaults work +has attribute => ( is => 'ro', default => 42, ); -has other_attribute => ( # Test BUILD method is called - is => 'rw' -); - -has punctuation => ( # Test BUILD method gets merged config - is => 'rw' -); - -has space => ( # Test that attribute slots get filled from merged config - is => 'ro' -); - -no Moose; - -__PACKAGE__->config(the_punctuation => ':'); -__PACKAGE__->config(space => ' '); # i am pbp, icm5ukp - -sub BUILD { - my ($self, $config) = @_; - # Note, not an example of something you would ever - $self->other_attribute('the meaning of life'); - $self->punctuation( $config->{the_punctuation} ); +sub get_attribute : Local { + my ($self, $c) = @_; + $c->response->body($self->attribute); } -sub the_answer : Local { +sub with_local_modifier : Local { my ($self, $c) = @_; - $c->response->body($self->other_attribute . $self->punctuation . $self->space . $self->attribute); + $c->forward('get_attribute'); } +before with_local_modifier => sub { + my ($self, $c) = @_; + $c->response->header( 'X-Catalyst-Test-Before' => 'before called' ); +}; + 1;