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