Model/Document/Role/Metaclass.pm

filter: Statementstmt 81.0% 30 / 37 Branchbran 50.0% 4 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 3 totaltotal 71.1% 42 / 59 SCAR 20.6
CC
7
Cov
74%
add_property
5.2
get_all_properties
2.3
_caller_info
2.0
CRAP 7.8
« Model/Index.pm ↑ Summary Model/Role.pm »
1 package Elasticsearch::Model::Document::Role::Metaclass;
2  
3 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5  
6 1 has shortname => (
7 is => 'ro',
8 builder => '_build_shortname',
9 lazy => 1,
10 );
11  
12 sub _build_shortname {
13 3 ▶ my $self = shift;
Subroutine _build_shortname: called CC=1 SCAR=0.0
14 3 ( my $name = $self->name ) =~ s/^.*:://;
15 3 return lc($name);
16 }
17  
18 1 has _all_properties => (
19 is => 'ro',
20 lazy => 1,
21 builder => '_build_all_properties',
22 );
23  
24 sub _build_all_properties {
25 return [
26 3 ▶ grep { $_->does('Elasticsearch::Model::Document::Attribute::Role::MappingParameters') }
Subroutine _build_all_properties: called CC=1 SCAR=0.0
27 shift->get_all_attributes
28 ];
29 }
30  
31 1 has _isa_arrayref => (
32 is => 'ro',
33 lazy => 1,
34 builder => '_build_isa_arrayref',
35 );
36  
37 sub _build_isa_arrayref {
38 return {
39 map {
40 0 $_->name => $_->isa_arrayref
41 0 ▶ } @{shift->_all_properties}
Subroutine _build_isa_arrayref: not called CC=1 SCAR=6.9
42 };
43 }
44  
45 sub mapping {
46 3 ▶ my $self = shift;
Subroutine mapping: called CC=1 SCAR=0.6
Pod undocumented
47 3 my $props = { map { $_->mapping } $self->get_all_properties };
48 return {
49 properties => $props,
50 3 map { $_->type_mapping } $self->get_all_properties,
51 };
52 }
53  
54 sub add_property {
55 18 ▶ my ( $self, $name ) = ( shift, shift );
Subroutine add_property: called CC=5 SCAR=16.6
Pod undocumented
56 18 ▶ Moose->throw_error('Usage: has \'name\' => ( key => value, ... )')
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 == 1 0 18 18
57 if @_ % 2 == 1;
58 18 my %options = ( definition_context => _caller_info(), @_ );
59 18 ▶ $options{traits} //= [];
Condition50%1/2
$options{"traits"} //= []
l!l
018
MC/DC0%0/1
$options{"traits"} //= []
$options{"traits"}
Truth table50%1/2
A
A= $options{"traits"}
Aresult
11
00
60 push(
61 18 @{ $options{traits} },
62 'Elasticsearch::Model::Document::Attribute::Role::MappingParameters'
63 );
64 18 ▶ my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ];
Branch: 1 branch
BranchTrueFalseTotal
ref $name eq 'ARRAY' ? : 0 18 18
65 18 $self->add_attribute( $_, %options ) for @$attrs;
66 }
67  
68 sub _caller_info {
69 18 ▶ my $level = @_ ? ( $_[0] + 1 ) : 2;
Subroutine _caller_info: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 18 18
70 18 my %info;
71 18 @info{qw(package file line)} = caller($level);
72 18 return \%info;
73 }
74  
75 sub get_all_properties {
76 6 ▶ my $self = shift;
Subroutine get_all_properties: called CC=2 SCAR=8.4
Pod undocumented
77 6 ▶ return @{$self->_all_properties}
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_immutable 6 0 6
78 if ($self->is_immutable);
79 0 return @{$self->_build_all_properties};
80 }
81  
82 1 1;
« Model/Index.pm ↑ Summary Model/Role.pm »