| 1 | package Elasticsearch::Model::Role::Metaclass; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | sub _handles { | ||||||||||
| 6 | 5 | ▶ | my ($s, $p) = @_; | ||||||||
|
Subroutine
_handles: called CC=1 SCAR=0.0
| |||||||||||
| 7 | return { | ||||||||||
| 8 | 5 | "get_$s" => 'get', | |||||||||
| 9 | "get_$p" => 'values', | ||||||||||
| 10 | "get_${s}_list" => 'keys', | ||||||||||
| 11 | "remove_$s" => 'delete', | ||||||||||
| 12 | "add_$s" => 'set', | ||||||||||
| 13 | }; | ||||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 1 | my %features = ( | |||||||||
| 17 | analyzer => 'analyzers', | ||||||||||
| 18 | tokenizer => 'tokenizers', | ||||||||||
| 19 | filter => 'filters', | ||||||||||
| 20 | normalizer => 'normalizers' | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | while (my ($s, $p) = each %features) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | has $p => ( | ||||||||||
| 25 | traits => ['Hash'], | ||||||||||
| 26 | isa => 'HashRef', | ||||||||||
| 27 | 8 | ▶ | default => sub { {} }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 4 | handles => _handles($s, $p) | |||||||||
| 29 | ); | ||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | has indices => ( | ||||||||||
| 33 | traits => ['Hash'], | ||||||||||
| 34 | isa => 'HashRef', | ||||||||||
| 35 | 2 | ▶ | default => sub { {default => {}} }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 36 | 1 | handles => (_handles('index', 'indices')), | |||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | sub namespaced_name_for_original_name { | ||||||||||
| 40 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
namespaced_name_for_original_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 41 | 1 | my @indices = $self->get_indices; | |||||||||
| 42 | my %namespaced_names = map { | ||||||||||
| 43 | 1 | $_->{name} => $_->{namespaced_name} | |||||||||
| 44 | 3 | } @indices; | |||||||||
| 45 | 1 | return \%namespaced_names; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | before add_index => sub { | ||||||||||
| 49 | 5 | ▶ | my ($self, $name, $index) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 50 | 5 | $self->remove_index('default'); | |||||||||
| 51 | 1 | }; | |||||||||
| 52 | |||||||||||
| 53 | 1 | has document_namespace => ( | |||||||||
| 54 | is => 'rw', | ||||||||||
| 55 | isa => 'Maybe[Str]', | ||||||||||
| 56 | ); | ||||||||||
| 57 | |||||||||||
| 58 | 1 | 1; | |||||||||