File Coverage

blib/lib/WebService/ValidSign/Object/DocumentPackage.pm
Criterion Covered Total %
statement 11 33 33.3
branch 0 10 0.0
condition n/a
subroutine 4 8 50.0
pod n/a
total 15 51 29.4


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