| 1 | package Elastic::Model::TypeMap::Moose; | ||||||||||||||||||||||||||||
| 2 | 23 | $Elastic::Model::TypeMap::Moose::VERSION = '0.52'; | |||||||||||||||||||||||||||
| 3 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 23 | ▶ | use Elastic::Model::TypeMap::Base qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 23 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | #=================================== | ||||||||||||||||||||||||||||
| 10 | has_type 'Any', | ||||||||||||||||||||||||||||
| 11 | #=================================== | ||||||||||||||||||||||||||||
| 12 | 0 | ▶ | deflate_via {'$val'}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | inflate_via {'$val'}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | map_via { type => 'object', enabled => 0 }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | #=================================== | ||||||||||||||||||||||||||||
| 17 | has_type 'Undef', | ||||||||||||||||||||||||||||
| 18 | #=================================== | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | map_via { type => 'string', index => 'not_analyzed' }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | #=================================== | ||||||||||||||||||||||||||||
| 22 | has_type 'Bool', | ||||||||||||||||||||||||||||
| 23 | #=================================== | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | map_via { type => 'boolean', null_value => 0 }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | #=================================== | ||||||||||||||||||||||||||||
| 27 | has_type 'Str', | ||||||||||||||||||||||||||||
| 28 | #=================================== | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | map_via { type => 'string' }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | #=================================== | ||||||||||||||||||||||||||||
| 32 | has_type 'Num', | ||||||||||||||||||||||||||||
| 33 | #=================================== | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | map_via { type => 'float' }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | #=================================== | ||||||||||||||||||||||||||||
| 37 | has_type 'Int', | ||||||||||||||||||||||||||||
| 38 | #=================================== | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | map_via { type => 'long' }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | #=================================== | ||||||||||||||||||||||||||||
| 42 | has_type 'ScalarRef', | ||||||||||||||||||||||||||||
| 43 | #=================================== | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | deflate_via {'$$val'}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | inflate_via {'\$val'}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | map_via { _content_handler( 'mapper', @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | #=================================== | ||||||||||||||||||||||||||||
| 49 | has_type 'CodeRef', | ||||||||||||||||||||||||||||
| 50 | #=================================== | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | deflate_via {undef}, inflate_via {undef}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | #=================================== | ||||||||||||||||||||||||||||
| 54 | has_type 'GlobRef', | ||||||||||||||||||||||||||||
| 55 | #=================================== | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | deflate_via {undef}, inflate_via {undef}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | #=================================== | ||||||||||||||||||||||||||||
| 59 | has_type 'FileHandle', | ||||||||||||||||||||||||||||
| 60 | #=================================== | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | deflate_via {undef}, inflate_via {undef}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | #=================================== | ||||||||||||||||||||||||||||
| 64 | has_type 'RegexpRef', | ||||||||||||||||||||||||||||
| 65 | #=================================== | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | deflate_via {undef}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | inflate_via {undef}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | map_via { type => 'string', index => 'no' }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | #=================================== | ||||||||||||||||||||||||||||
| 71 | has_type 'ArrayRef', | ||||||||||||||||||||||||||||
| 72 | #=================================== | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | deflate_via { _flate_array( 'deflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | inflate_via { _flate_array( 'inflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | map_via { _content_handler( 'mapper', @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | #=================================== | ||||||||||||||||||||||||||||
| 78 | has_type 'HashRef', | ||||||||||||||||||||||||||||
| 79 | #=================================== | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | deflate_via { _flate_hash( 'deflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | inflate_via { _flate_hash( 'inflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | map_via { type => 'object', enabled => 0 }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | #=================================== | ||||||||||||||||||||||||||||
| 85 | has_type 'Maybe', | ||||||||||||||||||||||||||||
| 86 | #=================================== | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | deflate_via { _flate_maybe( 'deflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | inflate_via { _flate_maybe( 'inflator', @_ ) }, map_via { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 89 | 0 | my $tc = $_[0]; | |||||||||||||||||||||||||||
| 90 | 0 | ▶ | return ( type => 'boolean' ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tc->can("type_parameter") and $tc->type_parameter->name eq "Bool"
MC/DC0%0/2
$tc->can("type_parameter") and $tc->type_parameter->name eq "Bool"
$tc->can("type_parameter")
$tc->type_parameter->name eq "Bool"
Truth table0%0/3
A and B
A= $tc->can("type_parameter")B= $tc->type_parameter->name eq "Bool"
| |||||||||||||||||||||||||||||
| 91 | if $tc->can('type_parameter') | ||||||||||||||||||||||||||||
| 92 | and $tc->type_parameter->name eq 'Bool'; | ||||||||||||||||||||||||||||
| 93 | 0 | _content_handler( 'mapper', @_ ); | |||||||||||||||||||||||||||
| 94 | 23 | }; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | #=================================== | ||||||||||||||||||||||||||||
| 97 | has_type 'Moose::Meta::TypeConstraint::Enum', | ||||||||||||||||||||||||||||
| 98 | #=================================== | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | deflate_via {'$val'}, # | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | inflate_via {'$val'}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 101 | 0 | ▶ | map_via { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 102 | 0 | type => 'string', | |||||||||||||||||||||||||||
| 103 | index => 'not_analyzed', | ||||||||||||||||||||||||||||
| 104 | 23 | }; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | #=================================== | ||||||||||||||||||||||||||||
| 107 | has_type 'Moose::Meta::TypeConstraint::Union', | ||||||||||||||||||||||||||||
| 108 | #=================================== | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | deflate_via {undef}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | inflate_via {undef}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | map_via { type => 'object', enabled => 0 }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | #=================================== | ||||||||||||||||||||||||||||
| 114 | has_type 'MooseX::Types::TypeDecorator', | ||||||||||||||||||||||||||||
| 115 | #=================================== | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | deflate_via { _decorated( 'deflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | inflate_via { _decorated( 'inflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | map_via { _decorated( 'mapper', @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | #=================================== | ||||||||||||||||||||||||||||
| 121 | has_type 'Moose::Meta::TypeConstraint::Parameterized', | ||||||||||||||||||||||||||||
| 122 | #=================================== | ||||||||||||||||||||||||||||
| 123 | 0 | ▶ | deflate_via { _parameterized( 'deflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | inflate_via { _parameterized( 'inflator', @_ ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | map_via { _parameterized( 'mapper', @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | #=================================== | ||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub _flate_array { | ||||||||||||||||||||||||||
|
Subroutine
_flate_array: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 129 | #=================================== | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | my $content = _content_handler(@_) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 132 | 0 | [ map { $content->($_) } @{ shift() } ]; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ref $content; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | 'do { [map { my $val = $_; ' . $content . '} @$val]}'; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | #=================================== | ||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub _flate_hash { | ||||||||||||||||||||||||||
|
Subroutine
_flate_hash: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 141 | #=================================== | ||||||||||||||||||||||||||||
| 142 | 0 | ▶ | my $content = _content_handler(@_) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 144 | 0 | my $hash = shift; | |||||||||||||||||||||||||||
| 145 | 0 | +{ map { $_ => $content->( $hash->{$_} ) } keys %$hash }; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ref $content; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | 'do { ' | |||||||||||||||||||||||||||
| 150 | . 'my $hash = $val; ' | ||||||||||||||||||||||||||||
| 151 | . '+{map { ' | ||||||||||||||||||||||||||||
| 152 | . 'my $key = $_; my $val = $hash->{$_}; ' | ||||||||||||||||||||||||||||
| 153 | . '$key => ' | ||||||||||||||||||||||||||||
| 154 | . $content | ||||||||||||||||||||||||||||
| 155 | . '} keys %$hash}}'; | ||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | #=================================== | ||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub _flate_maybe { | ||||||||||||||||||||||||||
|
Subroutine
_flate_maybe: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 160 | #=================================== | ||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $content = _content_handler(@_) or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | return defined $_[0] ? $content->( $_[0] ) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ref $content; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 0 | 'defined $val ? ' . $content . ' : undef'; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | #=================================== | ||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub _decorated { | ||||||||||||||||||||||||||
|
Subroutine
_decorated: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 171 | #=================================== | ||||||||||||||||||||||||||||
| 172 | 0 | my ( $type, $tc, $attr, $map ) = @_; | |||||||||||||||||||||||||||
| 173 | 0 | $map->find( $type, $tc->__type_constraint, $attr ); | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | #=================================== | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub _parameterized { | ||||||||||||||||||||||||||
|
Subroutine
_parameterized: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 178 | #=================================== | ||||||||||||||||||||||||||||
| 179 | 0 | my ( $type, $tc, $attr, $map ) = @_; | |||||||||||||||||||||||||||
| 180 | 0 | my $types = $type . 's'; | |||||||||||||||||||||||||||
| 181 | 0 | my $parent = $tc->parent; | |||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ( my $handler = $map->$types->{ $parent->name } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | return $handler->( $tc, $attr, $map ); | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | 0 | $map->find( $type, $parent, $attr ); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | #=================================== | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub _content_handler { | ||||||||||||||||||||||||||
|
Subroutine
_content_handler: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 190 | #=================================== | ||||||||||||||||||||||||||||
| 191 | 0 | my ( $type, $tc, $attr, $map ) = @_; | |||||||||||||||||||||||||||
| 192 | 0 | ▶ | return $tc->can('type_parameter') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 193 | ? $map->find( $type, $tc->type_parameter, $attr ) | ||||||||||||||||||||||||||||
| 194 | : $type eq 'mapper' ? ( type => 'object', enabled => 0 ) | ||||||||||||||||||||||||||||
| 195 | : '$val'; | ||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 23 | 1; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | =pod | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =head1 NAME | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | Elastic::Model::TypeMap::Moose - Type maps for core Moose types | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =head1 VERSION | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | version 0.52 | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | L<Elastic::Model::TypeMap::Moose> provides mapping, inflation and deflation | ||||||||||||||||||||||||||||
| 215 | for the core L<Moose::Util::TypeConstraints> and L<MooseX::Type::Moose> types. | ||||||||||||||||||||||||||||
| 216 | It is loaded automatically by L<Elastic::Model::TypeMap::Default>. | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | Definitions are inherited from parent type constraints, so a specific mapping | ||||||||||||||||||||||||||||
| 219 | may be provided for L</Int> but the deflation and inflation is handled by | ||||||||||||||||||||||||||||
| 220 | L</Any>. | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | =head1 TYPES | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | =head2 Any | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | No deflation or inflation is attempted - the value is passed unaltered. If it | ||||||||||||||||||||||||||||
| 227 | is not a value that L<JSON::XS> can handle (eg a blessed value) then | ||||||||||||||||||||||||||||
| 228 | deflation will fail. | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | It is mapped as: C<< { type => 'object', enabled => 0 } >>. | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | =head2 Item | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | Mapping and in/deflation via L</Any>. | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | =head2 Bool | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | In/deflation via L</Any>. It is mapped as: | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||
| 241 | type => 'boolean', | ||||||||||||||||||||||||||||
| 242 | null_value => 0 | ||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | =head2 Maybe | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | An undef value is stored as a JSON C<null>. The mapping and in/deflation depend | ||||||||||||||||||||||||||||
| 248 | on the content type, eg C<Maybe[Int]>. A C<Maybe> without a content | ||||||||||||||||||||||||||||
| 249 | type is mapped and in/deflated via L</Any>. C<Maybe[Bool]> is special cased | ||||||||||||||||||||||||||||
| 250 | to be mapped as: | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | { type => 'boolean' } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | See L<Elastic::Manual::Attributes/BOOLEAN FIELDS> for an explanation. | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | =head2 Undef | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | Mapped as C<< { type => 'string', index => 'not_analyzed' } >>. | ||||||||||||||||||||||||||||
| 259 | In/deflation via L</Any>. | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | =head2 Defined | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | Mapping and in/deflation via L</Any>. | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | =head2 Value | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | Mapping and in/deflation via L</Any>. | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | =head2 Str | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | Mapped as C<< { type => 'string' } >>. In/deflation via L</"Any">. | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =head2 Enum | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | Values are passed through without inflation/deflation. Mapped as: | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||
| 278 | type => 'string', | ||||||||||||||||||||||||||||
| 279 | index => 'not_analyzed' | ||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | =head2 Num | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | Mapped as C<< { type => 'float' } >>. In/deflation via L</Any>. | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | =head2 Int | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | Mapped as C<< { type => 'long' } >>. In/deflation via L</"Any">. | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | =head2 Ref | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | No delator, inflator or mapping provided. | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =head2 ScalarRef | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | The scalar value is dereferenced on deflation, and converted back | ||||||||||||||||||||||||||||
| 297 | to a scalar ref on inflation. The mapping depends on the content type, | ||||||||||||||||||||||||||||
| 298 | eg C<ScalarRef[Int]>. A C<ScalarRef> without a content type is mapped | ||||||||||||||||||||||||||||
| 299 | via L</Any>. | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =head2 ArrayRef | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | An array ref is preserved on inflation/deflation. The mapping depends on the | ||||||||||||||||||||||||||||
| 304 | content type, eg C<ArrayRef[Int]>. An C<ArrayRef> without a content | ||||||||||||||||||||||||||||
| 305 | type is mapped and in/deflated via L</Any>. For array refs with elements of | ||||||||||||||||||||||||||||
| 306 | different types, see L<Elastic::Model::TypeMap::Structured/"Tuple">. | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | =head2 HashRef | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | A hash ref is preserved on inflation/deflation. It is not advisable to allow | ||||||||||||||||||||||||||||
| 311 | arbitrary key names in indexed hashes, as you could end up generating many | ||||||||||||||||||||||||||||
| 312 | (and conflicting) field mappings. For this reason, HashRefs are mapped | ||||||||||||||||||||||||||||
| 313 | as C<< { type => 'object', enabled => 0 } >>. In/deflation depends on the | ||||||||||||||||||||||||||||
| 314 | content type (eg C<HashRef[Int>]). A C<HashRef> without a content type | ||||||||||||||||||||||||||||
| 315 | is in/deflated via L</Any>. | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | If you need a hashref which is indexed, then rather use either an object or | ||||||||||||||||||||||||||||
| 318 | L<Elastic::Model::TypeMap::Structure/"Dict">. | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | =head2 Ref | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | No delator, inflator or mapping provided. | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | =head2 RegexpRef | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | No delator or inflator is provided. It is mapped as: | ||||||||||||||||||||||||||||
| 327 | C<< { type => 'string', index => 'no' } >>. | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | =head2 GlobRef | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | No delator, inflator or mapping provided. | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | =head2 FileHandle | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | No delator, inflator or mapping provided. | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | Clinton Gormley <drtech@cpan.org> | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | This software is copyright (c) 2015 by Clinton Gormley. | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 346 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | =cut | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | __END__ | ||||||||||||||||||||||||||||