File Coverage

blib/lib/PDF/TableX/Stylable.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 1 1 100.0
total 11 11 100.0


line stmt bran cond sub pod time code
1             package PDF::TableX::Stylable;
2              
3 7     7   4345 use Moose::Role;
  7         21  
  7         48  
4 7     7   40338 use PDF::TableX::Types qw/StyleDefinition/;
  7         22  
  7         45  
5              
6             # public attributes for styles
7             has padding => (is => 'rw', isa => StyleDefinition, coerce => 1, default => sub{[1,1,1,1]} );
8             has border_width => (is => 'rw', isa => StyleDefinition, coerce => 1, default => sub{[1,1,1,1]} );
9             has border_color => (is => 'rw', isa => StyleDefinition, coerce => 1, default => 'black' );
10             has border_style => (is => 'rw', isa => StyleDefinition, coerce => 1, default => 'solid' );
11             has background_color => (is => 'rw', isa => 'Str', default => '' );
12             has text_align => (is => 'rw', isa => 'Str', default => 'left');
13             has font => (is => 'rw', isa => 'Any', default => 'Times');
14             has font_color => (is => 'rw', isa => 'Str', default => 'black');
15             has font_size => (is => 'rw', isa => 'Num', default => 12);
16             has margin => (is => 'rw', isa => StyleDefinition, coerce => 1, default => (10 / 25.4 *72) );
17              
18             has _children => (is => 'ro', init_arg => undef, isa => 'ArrayRef[ Object ]', default => sub {[]});
19              
20             for my $attr ( __PACKAGE__->attributes ) {
21             around $attr => sub {
22             my ($orig, $self, $value) = @_;
23             if ( defined $value ) {
24             $self->$orig($value);
25             for (@{$self->{_children}}) {
26             $_->$attr( $value );
27             }
28             return $self;
29             } else {
30             return $self->$orig;
31             }
32             };
33             }
34              
35             sub attributes {
36 188     188 1 942 return (grep !/^_/, __PACKAGE__->meta->get_attribute_list);
37             }
38              
39             1;
40              
41             =head1 NAME
42              
43             PDF::TableX::Stalable
44              
45             =head1 VERSION
46              
47             TODO
48              
49             =head1 SYNOPSIS
50              
51             TODO
52              
53             =head1 METHODS
54              
55             =head2 attributes
56              
57             TODO
58              
59             =head1 AUTHOR
60              
61             Grzegorz Papkala, C<< <grzegorzpapkala at gmail.com> >>
62              
63             =head1 BUGS
64              
65             Please report any bugs or feature requests at: L<https://github.com/grzegorzpapkala/PDF-TableX/issues>
66              
67             =head1 SUPPORT
68              
69             PDF::TableX is hosted on GitHub L<https://github.com/grzegorzpapkala/PDF-TableX>
70              
71             =head1 ACKNOWLEDGEMENTS
72              
73             =head1 COPYRIGHT & LICENSE
74              
75             Copyright 2013 Grzegorz Papkala, all rights reserved.
76              
77             This program is free software; you can redistribute it and/or modify it
78             under the same terms as Perl itself.
79              
80             =cut