line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::ValidSign::Object; |
2
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
3
|
3
|
|
|
3
|
|
1544
|
use Moo; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
17
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: A ValidSign object in use for the API |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1015
|
use Types::Standard qw(Str); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
18
|
|
8
|
3
|
|
|
3
|
|
2609
|
use String::CamelSnakeKebab qw(lower_camel_case lower_snake_case); |
|
3
|
|
|
|
|
35060
|
|
|
3
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has id => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => Str, |
13
|
|
|
|
|
|
|
predicate => 'has_id' |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has type => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => Str, |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
around BUILDARGS => sub { |
23
|
|
|
|
|
|
|
my $orig = shift; |
24
|
|
|
|
|
|
|
my $class = shift; |
25
|
|
|
|
|
|
|
my %args = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
return $orig->($class, |
28
|
|
|
|
|
|
|
map { lower_snake_case($_) => $args{$_} } keys %args); |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub TO_JSON { |
32
|
3
|
|
|
3
|
0
|
709
|
my $self = shift; |
33
|
3
|
|
|
|
|
17
|
my $meta = $self->meta; |
34
|
3
|
|
|
|
|
37
|
my %result; |
35
|
3
|
|
|
|
|
23
|
for my $attr ($meta->get_all_attributes) { |
36
|
27
|
|
|
|
|
601720
|
my $name = $attr->name; |
37
|
27
|
|
|
|
|
93
|
my $value = $attr->get_value($self); |
38
|
27
|
|
|
|
|
4400
|
my $type = $attr->type_constraint; |
39
|
|
|
|
|
|
|
|
40
|
27
|
100
|
|
|
|
240
|
if ($type) { |
41
|
21
|
100
|
|
|
|
140
|
if ($type->equals('Bool')) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
42
|
3
|
100
|
|
|
|
389
|
$value = $value ? \1 : \0; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif ($type->equals('ArrayRef')) { |
45
|
2
|
50
|
|
|
|
564
|
$value = undef if !@$value; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ($type->equals('HashRef')) { |
48
|
2
|
50
|
|
|
|
852
|
$value = undef if !keys %$value; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
27
|
100
|
|
|
|
6788
|
if (defined $value) { |
53
|
13
|
|
|
|
|
35
|
$name = lower_camel_case($name); |
54
|
13
|
50
|
|
|
|
415
|
$result{$name} = $value if defined $value; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
3
|
|
|
|
|
45
|
return \%result; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
WebService::ValidSign::Object - A ValidSign object in use for the API |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 0.002 |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Wesley Schwengle <waterkip@cpan.org> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Wesley Schwengle. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software, licensed under: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The (three-clause) BSD License |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |