Commit | Line | Data |
b68b4c7c |
1 | package TestApp::Controller::Moose; |
2 | |
3 | use Moose; |
4 | |
b68b4c7c |
5 | BEGIN { extends qw/Catalyst::Controller/; } |
6 | |
f04fdeda |
7 | has attribute => ( # Test defaults work |
b68b4c7c |
8 | is => 'ro', |
9 | default => 42, |
10 | ); |
11 | |
f04fdeda |
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 { |
b68b4c7c |
37 | my ($self, $c) = @_; |
f04fdeda |
38 | $c->response->body($self->other_attribute . $self->punctuation . $self->space . $self->attribute); |
b68b4c7c |
39 | } |
40 | |
41 | 1; |