File Coverage

blib/lib/Catalyst/Component/ApplicationAttribute.pm
Criterion Covered Total %
statement 6 7 85.7
branch n/a
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 10 80.0


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