Throwable/SugarFactory.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 34 / 34 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« MooX/BuildRole.pm ↑ Summary Throwable/SugarFactory/Hashable.pm »
1 package Throwable::SugarFactory;
2  
3 2 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Import::Into;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use MooX::SugarFactory ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Throwable::SugarFactory::Utils '_getglob';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Throwable ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '0.213360'; # VERSION
10  
11 # ABSTRACT: build a library of syntax-sugared Throwable-based exceptions
12  
13 #
14 # This file is part of Throwable-SugarFactory
15 #
16 #
17 # Christian Walde has dedicated the work to the Commons by waiving all of his
18 # or her rights to the work worldwide under copyright law and all related or
19 # neighboring legal rights he or she had in the work, to the extent allowable by
20 # law.
21 #
22 # Works under CC0 do not require attribution. When citing the work, you should
23 # not imply endorsement by the author.
24 #
25  
26  
27 3 ▶sub _base_args {
Subroutine _base_args: called CC=1 SCAR=0.0
28 3 my ( $namespace, $error, $description ) = @_;
29 return (
30 3 with => [ "Throwable", __PACKAGE__ . "::Hashable" ],
31 has => [ namespace => ( is => 'ro', default => $namespace ) ],
32 has => [ error => ( is => 'ro', default => $error ) ],
33 has => [ description => ( is => 'ro', default => $description ) ],
34 );
35 }
36  
37 1 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
38 1 MooX::SugarFactory->import::into( scalar caller ); # I::I 1.001000 syntax
39 1 my $factory = caller;
40 1 ▶ *{ _getglob $factory, "exception" } = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 3 my ( $id, $description, @args ) = @_;
42 3 my $class = "${factory}::$id";
43 3 $factory->can( "class" )->(
44 "$class->throw", _base_args( $factory, $id, $description ), @args
45 );
46 1 };
47 }
48  
49 2 1;
50  
51 __END__
« MooX/BuildRole.pm ↑ Summary Throwable/SugarFactory/Hashable.pm »