| 1 | package DBIx::NoSQL::Model::Field; | ||||||||||
| 2 | |||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 5 | ▶ | use Any::Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 5 | has name => qw/ is ro required 1 /; | |||||||||
| 9 | |||||||||||
| 10 | 5 | has index => qw/ is rw /; | |||||||||
| 11 | 5 | has type => qw/ is rw /; | |||||||||
| 12 | |||||||||||
| 13 | sub setup { | ||||||||||
| 14 | 12 | ▶ | my $self = shift; | ||||||||
|
Subroutine
setup: called CC=5 SCAR=20.9
Pod
undocumented
| |||||||||||
| 15 | 12 | my $model = shift; | |||||||||
| 16 | |||||||||||
| 17 | 12 | my %given = @_; | |||||||||
| 18 | |||||||||||
| 19 | 12 | ▶ | exists $given{ $_ } && $self->$_( $given{ $_ } ) for qw/ index /; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 12 | ▶ | if ( my $type_name = $given{ isa } ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 0 | $self->type( $type_name ); | |||||||||
| 22 | 0 | ▶ | if ( my $type = $model->store->type_map->type( $type_name ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | $model->_field2inflate_map->{ $self->name } = $type->inflator; | |||||||||
| 24 | 0 | $model->_field2deflate_map->{ $self->name } = $type->deflator; | |||||||||
| 25 | } | ||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 12 | return $self; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | sub install_index { | ||||||||||
| 32 | 12 | ▶ | my $self = shift; | ||||||||
|
Subroutine
install_index: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 33 | 12 | my $model = shift; | |||||||||
| 34 | 12 | my $result_class = shift; | |||||||||
| 35 | |||||||||||
| 36 | 12 | my $column = $self->name; | |||||||||
| 37 | |||||||||||
| 38 | 12 | $model->_field2column_map->{ $self->name } = $column; | |||||||||
| 39 | |||||||||||
| 40 | 12 | $result_class->add_column( $column => { | |||||||||
| 41 | data_type => 'text', | ||||||||||
| 42 | is_nullable => 1, | ||||||||||
| 43 | } ); | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 5 | 1; | |||||||||