| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebService::MinFraud::Role::Model; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2169
|
use Moo::Role; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
29
|
|
|
4
|
4
|
|
|
4
|
|
1407
|
use namespace::autoclean; |
|
|
4
|
|
|
|
|
16
|
|
|
|
4
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.009001'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
418
|
use Sub::Quote qw( quote_sub ); |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
252
|
|
|
9
|
4
|
|
|
4
|
|
28
|
use Types::Standard qw( HashRef ); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
40
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
requires '_has'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has raw => ( |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
isa => HashRef, |
|
16
|
|
|
|
|
|
|
required => 1, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
20
|
|
|
|
|
|
|
my $orig = shift; |
|
21
|
|
|
|
|
|
|
my $self = shift; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $p = $self->$orig(@_); |
|
24
|
|
|
|
|
|
|
delete $p->{raw}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# We make a copy to avoid a circular reference |
|
27
|
|
|
|
|
|
|
$p->{raw} = { %{$p} }; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $p; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) |
|
33
|
|
|
|
|
|
|
sub _define_model_attributes { |
|
34
|
6
|
|
|
6
|
|
18
|
my $class = shift; |
|
35
|
6
|
|
|
|
|
39
|
my %models = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
34
|
my $has = $class->can('_has'); |
|
38
|
|
|
|
|
|
|
|
|
39
|
6
|
|
|
|
|
23
|
for my $key ( keys %models ) { |
|
40
|
34
|
|
|
|
|
35208
|
my $record_class = "WebService::MinFraud::Record::$models{$key}"; |
|
41
|
|
|
|
|
|
|
|
|
42
|
34
|
|
|
|
|
96
|
my $raw_attr = '_raw_' . $key; |
|
43
|
|
|
|
|
|
|
|
|
44
|
34
|
|
|
|
|
121
|
$has->( |
|
45
|
|
|
|
|
|
|
$raw_attr => ( |
|
46
|
|
|
|
|
|
|
is => 'ro', |
|
47
|
|
|
|
|
|
|
isa => HashRef, |
|
48
|
|
|
|
|
|
|
init_arg => $key, |
|
49
|
|
|
|
|
|
|
default => quote_sub(q{ {} }), |
|
50
|
|
|
|
|
|
|
), |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
## no critic (ProhibitCallsToUnexportedSubs, RequireExplicitInclusion) |
|
54
|
|
|
|
|
|
|
$has->( |
|
55
|
|
|
|
|
|
|
$key => ( |
|
56
|
|
|
|
|
|
|
is => 'ro', |
|
57
|
|
|
|
|
|
|
isa => quote_sub( |
|
58
|
|
|
|
|
|
|
sprintf( |
|
59
|
|
|
|
|
|
|
q{ WebService::MinFraud::Types::object_isa_type( $_[0], %s ) }, |
|
60
|
|
|
|
|
|
|
B::perlstring($record_class) |
|
61
|
|
|
|
|
|
|
) |
|
62
|
|
|
|
|
|
|
), |
|
63
|
|
|
|
|
|
|
init_arg => undef, |
|
64
|
|
|
|
|
|
|
lazy => 1, |
|
65
|
|
|
|
|
|
|
default => quote_sub( |
|
66
|
|
|
|
|
|
|
sprintf( |
|
67
|
|
|
|
|
|
|
q{ $_[0]->_build_record( %s, %s ) }, |
|
68
|
34
|
|
|
|
|
12428
|
map { B::perlstring($_) } $record_class, $raw_attr |
|
|
68
|
|
|
|
|
2803
|
|
|
69
|
|
|
|
|
|
|
) |
|
70
|
|
|
|
|
|
|
), |
|
71
|
|
|
|
|
|
|
), |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
## use critic |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _build_record { |
|
78
|
37
|
|
|
37
|
|
119993
|
my $self = shift; |
|
79
|
37
|
|
|
|
|
89
|
my $record_class = shift; |
|
80
|
37
|
|
|
|
|
72
|
my $method = shift; |
|
81
|
|
|
|
|
|
|
|
|
82
|
37
|
|
|
|
|
180
|
my $raw = $self->$method; |
|
83
|
|
|
|
|
|
|
|
|
84
|
37
|
|
|
|
|
76
|
return $record_class->new( %{$raw}, locales => $self->locales ); |
|
|
37
|
|
|
|
|
721
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# ABSTRACT: A role for storing there original response in the raw attribute |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=encoding UTF-8 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
WebService::MinFraud::Role::Model - A role for storing there original response in the raw attribute |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 VERSION |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
version 1.009001 |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SUPPORT |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Bugs may be submitted through L<https://github.com/maxmind/minfraud-api-perl/issues>. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Mateu Hunter <mhunter@maxmind.com> |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This software is copyright (c) 2015 - 2019 by MaxMind, Inc. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
118
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |