File Coverage

blib/lib/Throwable/SugarFactory/Hashable.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             package Throwable::SugarFactory::Hashable;
2              
3 1     1   699 use strictures 2;
  1         5  
  1         38  
4 1     1   812 use Class::Inspector;
  1         3357  
  1         28  
5 1     1   5 use Moo::Role;
  1         2  
  1         7  
6              
7             our $VERSION = '0.152700'; # VERSION
8              
9             # ABSTRACT: role provides a generic to_hash function for Throwable exceptions
10              
11             #
12             # This file is part of Throwable-SugarFactory
13             #
14             #
15             # Christian Walde has dedicated the work to the Commons by waiving all of his
16             # or her rights to the work worldwide under copyright law and all related or
17             # neighboring legal rights he or she had in the work, to the extent allowable by
18             # law.
19             #
20             # Works under CC0 do not require attribution. When citing the work, you should
21             # not imply endorsement by the author.
22             #
23              
24              
25             sub to_hash {
26 3     3 1 11649 my ( $self ) = @_;
27 3         9 my @base_methods = qw( error namespace description previous_exception );
28 3         6 my %skip_methods = map { $_ => 1 } @base_methods,
  60         100  
29             qw( BUILDALL BUILDARGS DEMOLISHALL DOES after around before does extends
30             has meta new throw previous_exception to_hash with );
31 3         21 my $methods = Class::Inspector->methods( ref $self, 'public' );
32 3         913 my %data = map { $_ => $self->$_ } grep { !$skip_methods{$_} } @{$methods};
  1         7  
  58         87  
  3         6  
33 3         8 my %out = ( data => \%data, map { $_ => $self->$_ } @base_methods );
  12         38  
34 3         27 return \%out;
35             }
36              
37             1;
38              
39             __END__