Updating branch to current revision
[catagits/Catalyst-Runtime.git] / trunk / lib / Catalyst / Component / ApplicationAttribute.pm
CommitLineData
e28a6876 1package Catalyst::Component::ApplicationAttribute;
2
3use Moose::Role;
4use namespace::clean -except => 'meta';
5
6# Future - isa => 'ClassName|Catalyst' performance?
7# required => 1 breaks tests..
8has _application => (is => 'ro', weak_ref => 1);
9sub _app { (shift)->_application(@_) }
10
11override BUILDARGS => sub {
12 my ($self, $app) = @_;
13
14 my $args = super();
15 $args->{_application} = $app;
16
17 return $args;
18};
19
201;
21
22__END__
23
24=head1 NAME
25
26Catalyst::Component::ApplicationAttribute - Moose Role for components which capture the application context.
27
28=head1 SYNOPSIS
29
30 package My::Component;
31 use Moose;
32 extends 'Catalyst::Component';
33 with 'Catalyst::Component::ApplicationAttribute';
34
35 # Your code here
36
37 1;
38
39=head1 DESCRIPTION
40
41This role provides a BUILDARGS method which captures the application context into an attribute.
42
43=head1 ATTRIBUTES
44
45=head2 _application
46
47Weak reference to the application context.
48
49=head1 METHODS
50
51=head2 BUILDARGS ($self, $app)
52
53BUILDARGS method captures the application context into the C<_application> attribute.
54
55=head2 _application
56
57Reader method for the application context.
58
59=head1 SEE ALSO
60
61L<Catalyst::Component>,
62L<Catalyst::Controller>.
63
64=head1 AUTHORS
65
66Catalyst Contributors, see Catalyst.pm
67
68=head1 COPYRIGHT
69
70This library is free software. You can redistribute it and/or modify it under
71the same terms as Perl itself.
72
73=cut