File Coverage

blib/lib/Bread/Board/Service/WithConstructor.pm
Criterion Covered Total %
statement 13 13 100.0
branch 3 4 75.0
condition 2 3 66.6
subroutine 6 6 100.0
pod n/a
total 24 26 92.3


line stmt bran cond sub pod time code
1             package Bread::Board::Service::WithConstructor;
2             our $AUTHORITY = 'cpan:STEVAN';
3             $Bread::Board::Service::WithConstructor::VERSION = '0.35';
4 62     62   34713 use Moose::Role;
  62         163  
  62         555  
5              
6 62     62   342681 use Try::Tiny;
  62         166  
  62         11304  
7              
8             with 'Bread::Board::Service::WithClass';
9              
10             has 'constructor_name' => (
11             is => 'rw',
12             isa => 'Str',
13             lazy => 1,
14             builder => '_build_constructor_name',
15             );
16              
17             sub _build_constructor_name {
18 121     121   288 my $self = shift;
19              
20             # using Class::MOP::class_of on a Moo
21             # object causes mayhem, so we take care of that
22             # special case first. See GH#61
23 121 100   121   7338 try { $self->class->isa('Moo::Object') && 'new' }
24 118     118   8104 || try { Class::MOP::class_of($self->class)->constructor_name }
25 121 50 66     863 || 'new';
26             }
27              
28 62     62   479 no Moose; 1;
  62         155  
  62         402  
29              
30             __END__
31              
32             =pod
33              
34             =encoding UTF-8
35              
36             =head1 NAME
37              
38             Bread::Board::Service::WithConstructor
39              
40             =head1 VERSION
41              
42             version 0.35
43              
44             =head1 DESCRIPTION
45              
46             =head1 METHODS
47              
48             =over 4
49              
50             =item B<constructor_name>
51              
52             =back
53              
54             =head1 BUGS
55              
56             All complex software has bugs lurking in it, and this module is no
57             exception. If you find a bug please either email me, or add the bug
58             to cpan-RT.
59              
60             =head1 AUTHOR
61              
62             Stevan Little <stevan@iinteractive.com>
63              
64             =head1 BUGS
65              
66             Please report any bugs or feature requests on the bugtracker website
67             https://github.com/stevan/BreadBoard/issues
68              
69             When submitting a bug or request, please include a test-file or a
70             patch to an existing test-file that illustrates the bug or desired
71             feature.
72              
73             =head1 COPYRIGHT AND LICENSE
74              
75             This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive.
76              
77             This is free software; you can redistribute it and/or modify it under
78             the same terms as the Perl 5 programming language system itself.
79              
80             =cut