File Coverage

blib/lib/WebService/ValidSign/Object/DocumentPackage.pm
Criterion Covered Total %
statement 23 36 63.8
branch 3 10 30.0
condition n/a
subroutine 7 9 77.7
pod n/a
total 33 55 60.0


line stmt bran cond sub pod time code
1             ## Please see file perltidy.ERR
2             our $VERSION = '0.004';
3             use Moo;
4 2     2   1490  
  2         5  
  2         11  
5             extends 'WebService::ValidSign::Object';
6              
7             use Types::Standard qw(Str Bool ArrayRef HashRef);
8 2     2   1044 use WebService::ValidSign::Object::Ceremony;
  2         4  
  2         26  
9 2     2   3925  
  2         37  
  2         55  
10             # TODO:
11             # Add coerce sender
12             # Add coerce settings
13             # Add coerce roles
14             #
15             use WebService::ValidSign::Types qw();
16 2     2   13  
  2         3  
  2         772  
17             # ABSTRACT: A ValidSign DocumentPackage object
18              
19             has '+type' => (default => "PACKAGE");
20              
21             has name => (
22             is => 'ro',
23             required => 1,
24             );
25              
26             has language => (
27             is => 'rw',
28             isa => Str,
29             default => 'en',
30             );
31              
32             has email_message => (
33             is => 'rw',
34             isa => Str,
35             );
36              
37             has auto_complete => (
38             is => 'rw',
39             isa => Bool,
40             default => 1,
41             );
42              
43             has description => (
44             is => 'rw',
45             isa => Str,
46             );
47              
48             has sender => (
49             is => 'rw',
50             predicate => 'has_sender',
51             # coerce => 1
52             );
53              
54             has settings => (
55             is => 'rw',
56             builder => 1
57             );
58              
59             has visibility => (
60             is => 'rw',
61             isa => Str,
62             default => 'ACCOUNT',
63             );
64              
65             has roles => (
66             is => 'rw',
67             default => sub { [] },
68             isa => ArrayRef,
69             traits => ["Array"],
70             predicate => 'has_roles',
71              
72             #handles => {
73             # add_signer => 'push',
74             # count_signer => 'elements',
75             # delete_signer => 'delete',
76             #},
77             );
78              
79             has documents => (
80             is => 'rw',
81             lazy => 1,
82             isa => ArrayRef,
83             predicate => 'has_documents',
84             default => sub { [] },
85             );
86              
87             my $self = shift;
88             return { ceremony => WebService::ValidSign::Object::Ceremony->new() };
89 4     4   85 }
90 4         52  
91             my ($self, $document) = @_;
92             if ($self->count_documents) {
93             croak("Current implementation only supports one document!");
94 1     1   114 }
95 1 50       4  
96 0         0 push(@{$self->documents}, $document);
97             return 1;
98             };
99 1         2  
  1         18  
100 1         26 my $self = shift;
101             return 0 unless $self->has_documents;
102             return scalar @{$self->documents};
103             }
104 4     4   1316  
105 4 100       21  
106 3         6 my $self = shift;
  3         62  
107             my $role_name = shift;
108             my $signer = shift;
109             if ($self->count_roles) {
110             croak("Current implementation only supports one signer!");
111 0     0     }
112 0            
113 0           if (!$signer->can("as_signer")) {
114 0 0         croak("You need to implement as_signer");
115 0           }
116              
117             #push(@{$self->signers}, $signer->as_signer);
118 0 0         return 1;
119 0           };
120              
121             my $self = shift;
122             return 0 unless $self->has_roles;
123 0           return scalar @{$self->roles};
124             }
125              
126             __PACKAGE__->meta->make_immutable;
127 0     0      
128 0 0          
129 0           =pod
  0            
130              
131             =encoding UTF-8
132              
133             =head1 NAME
134              
135             WebService::ValidSign::Object::DocumentPackage - A ValidSign DocumentPackage object
136              
137             =head1 VERSION
138              
139             version 0.004
140              
141             =head1 AUTHOR
142              
143             Wesley Schwengle <waterkip@cpan.org>
144              
145             =head1 COPYRIGHT AND LICENSE
146              
147             This software is Copyright (c) 2019 by Wesley Schwengle.
148              
149             This is free software, licensed under:
150              
151             The (three-clause) BSD License
152              
153             =cut