Make Moose components collaberate with non-Moose Catalyst
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Moose.pm
1 package TestApp::Controller::Moose;
2
3 use Moose;
4
5 BEGIN { extends qw/Catalyst::Controller/; }
6
7 has attribute => ( # Test defaults work
8     is      => 'ro',
9     default => 42,
10 );
11
12 has other_attribute => ( # Test BUILD method is called
13     is => 'rw'
14 );
15
16 has punctuation => ( # Test BUILD method gets merged config
17     is => 'rw'
18 );
19
20 has space => ( # Test that attribute slots get filled from merged config
21     is => 'ro'
22 );
23
24 no Moose;
25
26 __PACKAGE__->config(the_punctuation => ':');
27 __PACKAGE__->config(space => ' '); # i am pbp, icm5ukp
28
29 sub BUILD {
30     my ($self, $config) = @_;
31     # Note, not an example of something you would ever
32     $self->other_attribute('the meaning of life');
33     $self->punctuation( $config->{the_punctuation} );
34 }
35
36 sub the_answer : Local {
37     my ($self, $c) = @_;
38     $c->response->body($self->other_attribute . $self->punctuation . $self->space . $self->attribute);
39 }
40
41 1;