Model/Document/Attribute/Role/MappingParameters.pm

filter: Statementstmt 61.4% 35 / 57 Branchbran 20.0% 2 / 10 Conditioncond 36.3% 4 / 11 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 50.0% 7 / 14 Podpod 0.0% 0 / 3 totaltotal 47.5% 48 / 101 SCAR 30.3
CC
10
Cov
53%
_build_basic_serialization
12.0
__ANON__
8.3
_build_isa_arrayref
6.0
CRAP 20.7
« Model/Document/Mapper.pm ↑ Summary Model/Index.pm »
1 package Elasticsearch::Model::Document::Attribute::Role::MappingParameters;
2  
3 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use MooseX::Types::Moose qw(ArrayRef HashRef);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Elasticsearch::Model::Document::Mapper;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 1 has basic_serialization => (
10 is => 'ro',
11 lazy => 1,
12 isa => 'HashRef',
13 builder => '_build_basic_serialization',
14 );
15  
16 sub _build_basic_serialization {
17 0 ▶ my $self = shift;
Subroutine _build_basic_serialization: not called CC=3 SCAR=24.8
18 my %basic_serialization =
19 map {
20 # Ensure that Bools get turned into words, i.e., true/false
21 0 my $is_bool = $self->meta->get_attribute($_)->type_constraint->name =~ /Bool/;
22 0 ▶ $_ => $is_bool ? ($self->$_ ? 'true' : 'false') : $self->$_;
Branch: 2 branches
BranchTrueFalseTotal
$is_bool ? : 0 0 0
$self->$_ ? : 0 0 0
23 }
24 0 grep { length $self->$_ }
25 0 grep { defined $self->$_ }
26 0 @{$self->mapping_parameters};
27 0 return \%basic_serialization;
28 }
29  
30 has mapping_parameters => (
31 is => 'ro',
32 isa => 'ArrayRef[Str]',
33 18 ▶ default => sub {[qw/
Subroutine __ANON__: called CC=1 SCAR=0.0
34 analyzer
35 coerce
36 copy_to
37 doc_values
38 dynamic
39 eager_global_ordinals
40 enabled
41 fielddata
42 fields
43 format
44 ignore_above
45 ignore_malformed
46 index
47 normalizer
48 null_value
49 position_increment_gap
50 search_analyzer
51 search_quote_analyzer
52 similarity
53 store
54 term_vector
55 type
56 /]},
57 1 );
58  
59 1 has [
60 qw/
61 copy_to
62 format
63 null_value
64 /
65 ] => (
66 is => 'ro',
67 isa => 'Maybe[Str]',
68 );
69  
70 1 has position_increment_gap => (
71 is => 'ro',
72 isa => 'Maybe[Int]',
73 );
74  
75 1 has [
76 qw/
77 analyzer
78 search_analyzer
79 search_quote_analyzer
80 normalizer
81 /
82 ] => (
83 is => 'ro',
84 isa => 'Maybe[Str]',
85 );
86  
87 1 has ignore_above => (
88 is => 'ro',
89 isa => 'Maybe[Int]',
90 );
91  
92 1 has similarity => (
93 is => 'ro',
94 isa => enum(
95 [
96 '', qw/
97 classic
98 boolean
99 BM25
100 /
101 ]
102 ),
103 default => '',
104 );
105  
106 1 has dynamic => (
107 is => 'ro',
108 isa => enum(
109 [
110 '', qw/
111 strict
112 true
113 false
114 /
115 ]
116 ),
117 default => '',
118 );
119  
120 1 has [qw/
121 coerce
122 enabled
123 fielddata
124 eager_global_ordinals
125 ignore_malformed
126 doc_values
127 index
128 store
129 /] => (
130 is => 'ro',
131 isa => 'Maybe[Bool]',
132 );
133  
134 1 has type => (
135 is => 'ro',
136 isa => enum(
137 [
138 '', qw/
139 binary
140 boolean
141 byte
142 circle
143 completion
144 date
145 date_range
146 double
147 double_range
148 envelope
149 float
150 float_range
151 geo_point
152 geo_shape
153 geometrycollection
154 half_float
155 integer
156 integer_range
157 ip
158 ip_range
159 join
160 keyword
161 linestring
162 long
163 long_range
164 multilinestring
165 multipoint
166 multipolygon
167 murmur3
168 nested
169 object
170 percolator
171 point
172 polygon
173 scaled_float
174 short
175 text
176 token_count
177 /
178 ]
179 ),
180 default => '',
181 );
182  
183 1 has fields => (
184 is => 'ro',
185 isa => 'Maybe[HashRef]',
186 );
187 1 has term_vector => (
188 is => 'ro',
189 isa => enum(
190 [
191 '', qw/
192 no
193 yes
194 with_positions
195 with_offsets
196 with_positions_offsets
197 /
198 ]
199 ),
200 default => '',
201 );
202 has field_name => (
203 is => 'ro',
204 isa => 'Str',
205 lazy => 1,
206 0 ▶ default => sub { shift->name },
Subroutine __ANON__: not called CC=1 SCAR=6.9
207 1 );
208  
209 1 has isa_arrayref => (
210 is => 'ro',
211 lazy => 1,
212 isa => 'Bool',
213 builder => '_build_isa_arrayref'
214 );
215  
216 sub _build_isa_arrayref {
217 0 ▶ my $self = shift;
Subroutine _build_isa_arrayref: not called CC=2 SCAR=17.9
218 0 my $tc = $self->type_constraint;
219 0 ▶ return 0 unless $tc;
Branch: 1 branch
BranchTrueFalseTotal
unless $tc 0 0 0
220 0 return $tc->is_a_type_of("ArrayRef");
221 }
222  
223 sub build_property {
224 0 ▶ my $self = shift;
Subroutine build_property: not called CC=1 SCAR=6.9
Pod undocumented
225 0 return Elasticsearch::Model::Document::Mapper::maptc(
226 $self, $self->type_constraint
227 );
228 }
229  
230 before _process_options => sub {
231 18 ▶ my ($self, $name, $options) = @_;
Subroutine __ANON__: called CC=4 SCAR=16.1
232 %$options = (
233 builder => 'build_id',
234 lazy => 1,
235 %$options
236 ) if (
237 $options->{id}
238 18 ▶ and ref $options->{id} eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"id"} and ref $options->{"id"} eq "ARRAY" 0 18 18
Condition33%1/3
$options->{"id"} and ref $options->{"id"} eq "ARRAY"
!ll&&!rl&&r
1800
MC/DC0%0/2
$options->{"id"} and ref $options->{"id"} eq "ARRAY"
$options->{"id"} ref $options->{"id"} eq "ARRAY"
Truth table33%1/3
A and B
A= $options->{"id"}B= ref $options->{"id"} eq "ARRAY"
ABresult
0X0
100
111
239 );
240  
241 18 ▶ $options->{traits} //= [];
Condition50%1/2
$options->{"traits"} //= []
l!l
180
MC/DC0%0/1
$options->{"traits"} //= []
$options->{"traits"}
Truth table50%1/2
A
A= $options->{"traits"}
Aresult
11
00
242 1 };
243  
244 after _process_options => sub {
245 18 ▶ my ($class, $name, $options) = @_;
Subroutine __ANON__: called CC=4 SCAR=21.1
246 18 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"required"} and not $options->{"builder"} and not defined $options->{"default"}) 0 18 18
Condition33%2/6
$options->{"required"} and not $options->{"builder"} and not defined $options->{"default"}
!ll&&!rl&&r
1800
$options->{"required"} and not $options->{"builder"}
!ll&&!rl&&r
1800
MC/DC0%0/3
$options->{"required"} and not $options->{"builder"} and not defined $options->{"default"}
$options->{"required"} not $options->{"builder"} not defined $options->{"default"}
Truth table25%1/4
A and not(B) and not(C)
A= $options->{"required"}B= not $options->{"builder"}C= not defined $options->{"default"}
ABCresult
0XX0
10X0
1100
1111
247 $options->{required}
248 and not $options->{builder}
249 and not defined $options->{default}
250 ) {
251 0 $options->{lazy} = 1;
252 0 $options->{required} = 1;
253 $options->{default} = sub {
254 0 ▶ confess "Attribute $name is required";
Subroutine __ANON__: not called CC=1 SCAR=6.9
255 0 };
256 }
257 1 };
258  
259 sub mapping {
260 0 ▶ my $self = shift;
Subroutine mapping: not called CC=1 SCAR=6.9
Pod undocumented
261 0 return ($self->name => { $self->build_property });
262 }
263  
264 0 ▶sub type_mapping { () }
Subroutine type_mapping: not called CC=1 SCAR=6.9
Pod undocumented
265  
266 1 1;
« Model/Document/Mapper.pm ↑ Summary Model/Index.pm »