line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of ElasticSearchX-Model |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2019 by Moritz Onken. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The (three-clause) BSD License |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package ElasticSearchX::Model::Trait::Class; |
11
|
|
|
|
|
|
|
$ElasticSearchX::Model::Trait::Class::VERSION = '2.0.1'; |
12
|
11
|
|
|
11
|
|
39037
|
use Moose::Role; |
|
11
|
|
|
|
|
41
|
|
|
11
|
|
|
|
|
112
|
|
13
|
11
|
|
|
11
|
|
58656
|
use List::Util (); |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
202
|
|
14
|
11
|
|
|
11
|
|
61
|
use Carp; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
3966
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _handles { |
17
|
44
|
|
|
44
|
|
102
|
my ( $s, $p ) = @_; |
18
|
|
|
|
|
|
|
return { |
19
|
44
|
|
|
|
|
349
|
"get_$s" => 'get', |
20
|
|
|
|
|
|
|
"get_$p" => 'values', |
21
|
|
|
|
|
|
|
"get_${s}_list" => 'keys', |
22
|
|
|
|
|
|
|
"remove_$s" => 'delete', |
23
|
|
|
|
|
|
|
"add_$s" => 'set', |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
my %foo = ( |
27
|
|
|
|
|
|
|
analyzer => 'analyzers', |
28
|
|
|
|
|
|
|
tokenizer => 'tokenizers', |
29
|
|
|
|
|
|
|
filter => 'filters' |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
while ( my ( $s, $p ) = each %foo ) { |
32
|
|
|
|
|
|
|
has $p => ( |
33
|
|
|
|
|
|
|
traits => ['Hash'], |
34
|
|
|
|
|
|
|
isa => 'HashRef', |
35
|
|
|
|
|
|
|
default => sub { {} }, |
36
|
|
|
|
|
|
|
handles => _handles( $s, $p ) |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has indices => ( |
41
|
|
|
|
|
|
|
traits => ['Hash'], |
42
|
|
|
|
|
|
|
isa => 'HashRef', |
43
|
|
|
|
|
|
|
default => sub { { default => {} } }, |
44
|
|
|
|
|
|
|
handles => _handles( 'index', 'indices' ) |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
before add_index => sub { |
48
|
|
|
|
|
|
|
my ( $self, $name, $index ) = @_; |
49
|
|
|
|
|
|
|
$self->remove_index('default'); |
50
|
|
|
|
|
|
|
if ( $index->{alias_for} && $name ne $index->{alias_for} ) { |
51
|
|
|
|
|
|
|
return $self->add_index( $index->{alias_for}, $index ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=encoding UTF-8 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
ElasticSearchX::Model::Trait::Class |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 VERSION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
version 2.0.1 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Moritz Onken |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This software is Copyright (c) 2019 by Moritz Onken. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This is free software, licensed under: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The (three-clause) BSD License |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |