File Coverage

blib/lib/Bread/Board/LifeCycle/Session/WithParameters.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Bread::Board::LifeCycle::Session::WithParameters;
2              
3             our $AUTHORITY = 'cpan:GSG';
4             our $VERSION = '0.90';
5              
6 1     1   9390 use Moose::Role;
  1         4  
  1         9  
7 1     1   5878 use Module::Runtime ();
  1         2  
  1         34  
8 1     1   8 use namespace::autoclean;
  1         2  
  1         12  
9              
10             our $FLUSHER_ROLE = 'Bread::Board::Container::Role::WithSessions';
11              
12             with 'Bread::Board::LifeCycle::Singleton::WithParameters';
13              
14             ### XXX: Lifecycle consumption happens after service construction,
15             ### so we have pick a method that would get called after
16             ### construction. The 'get' method is pretty hot, so this should
17             ### be done as fast as possible.
18              
19             before get => sub {
20             my $self = shift;
21              
22             # Assume we've already done this if any instance exists
23             return if values %{$self->instances};
24              
25             Module::Runtime::require_module($FLUSHER_ROLE);
26              
27             my @containers = ($self->get_root_container);
28              
29             # Traverse the sub containers and apply the WithSessions role
30             while (my $container = shift @containers) {
31             push @containers, values %{$container->sub_containers};
32              
33             Class::MOP::class_of($FLUSHER_ROLE)->apply($container)
34             unless $container->meta->does_role($FLUSHER_ROLE);
35             }
36             };
37              
38             1;
39              
40             __END__
41              
42             =pod
43              
44             =encoding UTF-8
45              
46             =head1 NAME
47              
48             Bread::Board::LifeCycle::Session::WithParameters
49              
50             =head1 VERSION
51              
52             version v0.900.1
53              
54             =head1 DESCRIPTION
55              
56             This lifecycle type is a flushable version of L<Bread::Board::LifeCycle::Singleton::WithParameters>. Like
57             L<Session|Bread::Board::LifeCycle::Session>, the same L<flush_session_instances|Bread::Board::Container::Role::WithSessions/flush_session_instances>
58             method is applied to all of its containers.
59              
60             =head1 NAME
61              
62             Bread::Board::LifeCycle::Session::WithParameters
63              
64             =head1 VERSION
65              
66             version 0.90
67              
68             =head1 AUTHOR
69              
70             Brendan Byrd C<< <BBYRD@CPAN.org> >>
71              
72             =head1 LICENSE AND COPYRIGHT
73              
74             Copyright 2015 Grant Street Group
75              
76             This program is free software; you can redistribute it and/or modify it
77             under the terms of the the Artistic License (2.0). You may obtain a
78             copy of the full license at:
79              
80             L<http://www.perlfoundation.org/artistic_license_2_0>
81              
82             Any use, modification, and distribution of the Standard or Modified
83             Versions is governed by this Artistic License. By using, modifying or
84             distributing the Package, you accept this license. Do not use, modify,
85             or distribute the Package, if you do not accept this license.
86              
87             If your Modified Version has been derived from a Modified Version made
88             by someone other than you, you are nevertheless required to ensure that
89             your Modified Version complies with the requirements of this license.
90              
91             This license does not grant you the right to use any trademark, service
92             mark, tradename, or logo of the Copyright Holder.
93              
94             This license includes the non-exclusive, worldwide, free-of-charge
95             patent license to make, have made, use, offer to sell, sell, import and
96             otherwise transfer the Package with respect to any patent claims
97             licensable by the Copyright Holder that are necessarily infringed by the
98             Package. If you institute patent litigation (including a cross-claim or
99             counterclaim) against any party alleging that the Package constitutes
100             direct or contributory patent infringement, then this Artistic License
101             to you shall terminate on the date that such litigation is filed.
102              
103             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
104             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
105             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
106             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
107             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
108             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
109             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
110             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111              
112             =head1 AUTHOR
113              
114             Grant Street Group <developers@grantstreet.com>
115              
116             =head1 COPYRIGHT AND LICENSE
117              
118             This software is Copyright (c) 2015 - 2020 by Grant Street Group.
119              
120             This is free software, licensed under:
121              
122             The Artistic License 2.0 (GPL Compatible)
123              
124             =cut