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   618 use strictures 2;
  1         6  
  1         38  
4 1     1   626 use Class::Inspector;
  1         3612  
  1         33  
5 1     1   8 use Moo::Role;
  1         2  
  1         7  
6              
7             our $VERSION = '0.213360'; # 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 12567 my ( $self ) = @_;
27 3         9 my @base_methods = qw( error namespace description previous_exception );
28 3         9 my %skip_methods = map { $_ => 1 } @base_methods,
  63         161  
29             qw( BUILDALL BUILDARGS DEMOLISHALL DOES after around before does extends
30             has meta new throw previous_exception to_hash with new_with_previous );
31 3         22 my $methods = Class::Inspector->methods( ref $self, 'public' );
32 3         1127 my %data = map { $_ => $self->$_ } grep { !$skip_methods{$_} } @{$methods};
  1         7  
  61         108  
  3         7  
33 3         9 my %out = ( data => \%data, map { $_ => $self->$_ } @base_methods );
  12         54  
34 3         39 return \%out;
35             }
36              
37             1;
38              
39             __END__