| 1 | package Elasticsearch::Model::Role; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use Module::Find; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use Class::Load; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Search::Elasticsearch 6.00; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | has es => ( | |||||||||||||||||||
| 11 | is => 'ro', | ||||||||||||||||||||
| 12 | lazy => 1, | ||||||||||||||||||||
| 13 | builder => '_build_es', | ||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | sub _build_es { | ||||||||||||||||||||
| 17 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_build_es: called CC=2 SCAR=7.2
| |||||||||||||||||||||
| 18 | return Search::Elasticsearch->new( | ||||||||||||||||||||
| 19 | 1 | ▶ | nodes => $ENV{ES} || '127.0.0.1:9200', | ||||||||||||||||||
|
Condition50%1/2
$ENV{'ES'} || '127.0.0.1:9200'
MC/DC0%0/1
$ENV{'ES'} || '127.0.0.1:9200'
$ENV{'ES'}
Truth table50%1/2
A
A= $ENV{'ES'}
| |||||||||||||||||||||
| 20 | cxn => 'HTTPTiny', | ||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 1 | has document_types => ( | |||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||
| 26 | isa => 'Maybe[ArrayRef]', | ||||||||||||||||||||
| 27 | lazy => 1, | ||||||||||||||||||||
| 28 | builder => '_build_document_types', | ||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | sub _build_document_types { | ||||||||||||||||||||
| 32 | 1 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_build_document_types: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 33 | my @found = | ||||||||||||||||||||
| 34 | 3 | grep { $_->isa('Moose::Object') } | |||||||||||||||||||
| 35 | 1 | map { Class::Load::load_class($_) } | |||||||||||||||||||
| 36 | findallmod($self->document_namespace); | ||||||||||||||||||||
| 37 | 1 | return \@found; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 1 | has document_namespace => ( | |||||||||||||||||||
| 41 | is => 'ro', | ||||||||||||||||||||
| 42 | isa => 'Str', | ||||||||||||||||||||
| 43 | lazy => 1, | ||||||||||||||||||||
| 44 | builder => '_build_document_namespace', | ||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | sub _build_document_namespace { | ||||||||||||||||||||
| 48 | 7 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
_build_document_namespace: called CC=2 SCAR=7.1
| |||||||||||||||||||||
| 49 | 7 | ▶ | return $self->meta->document_namespace // ref $self; | ||||||||||||||||||
|
Condition66%2/3
$self->meta->document_namespace // ref $self
MC/DC0%0/2
$self->meta->document_namespace // ref $self
$self->meta->document_namespace
ref $self
Truth table66%2/3
A // B
A= $self->meta->document_namespaceB= ref $self
| |||||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | sub deploy { | ||||||||||||||||||||
| 53 | 0 | ▶ | my ($self, %params) = @_; | ||||||||||||||||||
|
Subroutine
deploy: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 0 | my $t = $self->es->transport; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 0 | foreach my $original_name ($self->meta->get_index_list) { | |||||||||||||||||||
| 58 | my $name = | ||||||||||||||||||||
| 59 | 0 | $self->meta->namespaced_name_for_original_name->{$original_name}; | |||||||||||||||||||
| 60 | 0 | my $index_obj = $self->index($original_name); | |||||||||||||||||||
| 61 | 0 | ▶ | if ($params{delete}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 0 | $self->es->indices->delete(index => $name, ignore_unavailable => 'true'); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | 0 | $index_obj->deploy_to(index_name => $name); | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | 0 | return 1; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 1 | 1; | |||||||||||||||||||