| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Database Object Interface - ~/lib/DB/Object/Fields.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v1.3.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2026 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2020/01/01 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/08/05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## under the same terms as Perl itself.## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ##----------------------------------------------------------------------------## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package DB::Object::Fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | warnings::register_categories( 'DB::Object' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use vars qw( $VERSION $EXCEPTION_CLASS ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use DB::Object::Fields::Field; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | our $EXCEPTION_CLASS = $DB::Object::EXCEPTION_CLASS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | our $VERSION = 'v1.3.1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->{prefixed} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # Property 'query_object' not used anymore. Instead, we use table_object->query_object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $self->{table_object} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # $self->{fatal} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $self->{_init_params_order} = [qw( table_object query_object prefixed )]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->{_exception_class} = $EXCEPTION_CLASS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self->SUPER::init( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $self->{_fields} = [qw( prefixed )]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return( $self->error( "No table object was provided" ) ) if( !$self->{table_object} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub database_object { return( shift->table_object->database_object ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
database_object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # To manually create a new table field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub new_field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_field: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $opts = $self->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if( !exists( $opts->{name} ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
not exists $opts->{"name"} or $self->_is_empty($opts->{"name"})
MC/DC0%0/2
not exists $opts->{"name"} or $self->_is_empty($opts->{"name"})
not exists $opts->{"name"}
$self->_is_empty($opts->{"name"})
Truth table0%0/3
not(A) or B
A= not exists $opts->{"name"}B= $self->_is_empty($opts->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $self->_is_empty( $opts->{name} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return( $self->error( "No field name was provided." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ▶ | elsif( !exists( $opts->{type} ) || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not exists $opts->{"type"} or $self->_is_empty($opts->{"type"})
MC/DC0%0/2
not exists $opts->{"type"} or $self->_is_empty($opts->{"type"})
not exists $opts->{"type"}
$self->_is_empty($opts->{"type"})
Truth table0%0/3
not(A) or B
A= not exists $opts->{"type"}B= $self->_is_empty($opts->{"type"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | $self->_is_empty( $opts->{type} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return( $self->error( "No field type was provided." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $opts->{type} = lc( $opts->{type} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # But actually we ignore it; users should not provide it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if( exists( $opts->{constant} ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $opts->{"constant"} and defined $opts->{"constant"} and ref $opts->{"constant"} eq "HASH"
exists $opts->{"constant"} and defined $opts->{"constant"}
MC/DC0%0/3
exists $opts->{"constant"} and defined $opts->{"constant"} and ref $opts->{"constant"} eq "HASH"
exists $opts->{"constant"}
defined $opts->{"constant"}
ref $opts->{"constant"} eq "HASH"
Truth table0%0/4
A and B and C
A= exists $opts->{"constant"}B= defined $opts->{"constant"}C= ref $opts->{"constant"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | defined( $opts->{constant} ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ref( $opts->{constant} ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $opts->{datatype} = delete( $opts->{constant} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $datatype_dict = $self->database_object->datatype_dict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if( !exists( $datatype_dict->{ $opts->{type} } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return( $self->error( "Field type provided ($opts->{type}) is not supported by driver ", $self->database_object->driver ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $def = $datatype_dict->{ $opts->{type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $opts->{debug} = $self->debug unless( exists( $opts->{debug} ) && length( $opts->{debug} // '' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
exists $opts->{"debug"} and length($opts->{"debug"} // "")
$opts->{"debug"} // ""
MC/DC0%0/2
exists $opts->{"debug"} and length($opts->{"debug"} // "")
exists $opts->{"debug"}
$opts->{"debug"}
Truth table0%0/3
A and B
A= exists $opts->{"debug"}B= $opts->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | my $fo = DB::Object::Fields::Field->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | datatype => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | constant => $def->{constant}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | name => $def->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | type => $def->{type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | debug => $opts->{debug}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | ( !$self->_is_empty( $opts->{default} ) ? ( default => $opts->{default} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ( !$self->_is_empty( $opts->{is_array} ) ? ( is_array => $opts->{is_array} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | ( !$self->_is_empty( $opts->{is_nullable} ) ? ( is_nullable => $opts->{is_nullable} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | name => $opts->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ( !$self->_is_empty( $opts->{pos} ) ? ( pos => $opts->{pos} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | query_object => $self->query_object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ( !$self->_is_empty( $opts->{size} ) ? ( size => $opts->{size} ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | table_object => $self->table_object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | type => $opts->{type}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | ) || return( $self->pass_error( DB::Object::Fields::Field->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/2
'DB::Object::Fields::Field'->new('datatype', {'constant', $def->{'constant'}, 'name', $def->{'name'}, 'type', $def->{'type'}}, 'debug', $opts->{'debug'}, !$self->_is_empty($opts->{'default'}) ? ('default', $opts->{'default'}) : (), !$self->_is_empty($opts->{'is_array'}) ? ('is_array', $opts->{'is_array'}) : (), !$self->_is_empty($opts->{'is_nullable'}) ? ('is_nullable', $opts->{'is_nullable'}) : (), 'name', $opts->{'name'}, !$self->_is_empty($opts->{'pos'}) ? ('pos', $opts->{'pos'}) : (), 'query_object', $self->query_object, !$self->_is_empty($opts->{'size'}) ? ('size', $opts->{'size'}) : (), 'table_object', $self->table_object, 'type', $opts->{'type'}) || (return $self->pass_error('DB::Object::Fields::Field'->error))
MC/DC0%0/1
'DB::Object::Fields::Field'->new('datatype', {'constant', $def->{'constant'}, 'name', $def->{'name'}, 'type', $def->{'type'}}, 'debug', $opts->{'debug'}, !$self->_is_empty($opts->{'default'}) ? ('default', $opts->{'default'}) : (), !$self->_is_empty($opts->{'is_array'}) ? ('is_array', $opts->{'is_array'}) : (), !$self->_is_empty($opts->{'is_nullable'}) ? ('is_nullable', $opts->{'is_nullable'}) : (), 'name', $opts->{'name'}, !$self->_is_empty($opts->{'pos'}) ? ('pos', $opts->{'pos'}) : (), 'query_object', $self->query_object, !$self->_is_empty($opts->{'size'}) ? ('size', $opts->{'size'}) : (), 'table_object', $self->table_object, 'type', $opts->{'type'}) || (return $self->pass_error('DB::Object::Fields::Field'->error))
'DB::Object::Fields::Field'->new('datatype', {'constant', $def->{'constant'}, 'name', $def->{'name'}, 'type', $def->{'type'}}, 'debug', $opts->{'debug'}, !$self->_is_empty($opts->{'default'}) ? ('default', $opts->{'default'}) : (), !$self->_is_empty($opts->{'is_array'}) ? ('is_array', $opts->{'is_array'}) : (), !$self->_is_empty($opts->{'is_nullable'}) ? ('is_nullable', $opts->{'is_nullable'}) : (), 'name', $opts->{'name'}, !$self->_is_empty($opts->{'pos'}) ? ('pos', $opts->{'pos'}) : (), 'query_object', $self->query_object, !$self->_is_empty($opts->{'size'}) ? ('size', $opts->{'size'}) : (), 'table_object', $self->table_object, 'type', $opts->{'type'})
Truth table0%0/2
A
A= 'DB::Object::Fields::Field'->new('datatype', {'constant', $def->{'constant'}, 'name', $def->{'name'}, 'type', $def->{'type'}}, 'debug', $opts->{'debug'}, !$self->_is_empty($opts->{'default'}) ? ('default', $opts->{'default'}) : (), !$self->_is_empty($opts->{'is_array'}) ? ('is_array', $opts->{'is_array'}) : (), !$self->_is_empty($opts->{'is_nullable'}) ? ('is_nullable', $opts->{'is_nullable'}) : (), 'name', $opts->{'name'}, !$self->_is_empty($opts->{'pos'}) ? ('pos', $opts->{'pos'}) : (), 'query_object', $self->query_object, !$self->_is_empty($opts->{'size'}) ? ('size', $opts->{'size'}) : (), 'table_object', $self->table_object, 'type', $opts->{'type'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | return( $fo ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | sub prefixed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefixed: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $self->{prefixed} = ( $_[0] =~ /^\d+$/ ? $_[0] : ( $_[0] ? 1 : 0 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $self->{prefixed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $fields = $self->table_object->fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | foreach my $f ( keys( %$fields ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | next if( !CORE::length( $self->{ $f } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | next if( !$self->_is_object( $self->{ $f } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $o = $self->{ $f }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $o->prefixed( $self->{prefixed} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # sub query_object { return( shift->_set_get_object_without_init( 'query_object', 'DB::Object::Query', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub query_object { return( shift->table_object->query_object ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub table_object { return( shift->_set_get_object_without_init( 'table_object', 'DB::Object::Tables', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | sub _initiate_field_object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initiate_field_object: not called CC=5 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my $field = shift( @_ ) || return( $self->error( "No field was provided to get its object." ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ || (return $self->error('No field was provided to get its object.'))
MC/DC0%0/1
shift @_ || (return $self->error('No field was provided to get its object.'))
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $tbl = $self->table_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $fields = $tbl->fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | return( $self->error( "Table ", $tbl->name, " has no such field \"$field\"." ) ) if( !CORE::exists( $fields->{ $field } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $code = $self->can( $field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | unless( defined( $code ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | $code = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | unless( $self->{ $field } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $fo = $tbl->fields( $field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $fo->debug( ( $self->debug // 0 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->debug // 0
MC/DC0%0/1
$self->debug // 0
$self->debug
Truth table0%0/2
A
A= $self->debug
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $fo->prefixed( $self->{prefixed} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $fo->query_object( $self->table_object->query_object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $fo->table_object( $self->table_object ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $self->{ $field } = $fo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | return( $self->{ $field } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | *{"$field"} = $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $o = $code->( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return( $o ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # NOTE: AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=11 SCAR=46.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my( $method ) = our $AUTOLOAD =~ /([^:]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # my( $class, $method ) = our $AUTOLOAD =~ /^(.*?)::([^\:]+)$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 4 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $fields = $self->table_object->fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if( my $code = $self->can( $method ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | return( $code->( $self, @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | elsif( exists( $fields->{ $method } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return( $self->_initiate_field_object( $method ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # This is an unrecoverable error. We have no choice, but to die. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $error = "Table " . $self->table_object->name . " has no such field \"$method\""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | $self->_load_class( 'Module::Generic::Exception' ) || die( $self->error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $exception = Module::Generic::Exception->new( $error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $on_unknown_field = $self->table_object->database_object->unknown_field; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if( ref( $on_unknown_field ) eq 'CODE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | return( $on_unknown_field->({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | table => $self->table_object, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | field => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | error => $exception, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | }) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | ▶ | elsif( defined( $on_unknown_field ) && ( $on_unknown_field eq 'die' || $on_unknown_field eq 'fatal' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
defined $on_unknown_field and $on_unknown_field eq "die" || $on_unknown_field eq "fatal"
$on_unknown_field eq "die" or $on_unknown_field eq "fatal"
MC/DC0%0/3
defined $on_unknown_field and $on_unknown_field eq "die" || $on_unknown_field eq "fatal"
defined $on_unknown_field
$on_unknown_field eq "die"
$on_unknown_field eq "fatal"
Truth table0%0/4
A and B or C
A= defined $on_unknown_fieldB= $on_unknown_field eq "die"C= $on_unknown_field eq "fatal"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | die( $exception ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | $self->_load_class( 'DB::Object::Fields::Unknown' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | die( "${error}, and I could not load the module DB::Object::Fields::Unknown: ", $self->error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | my $unknown = DB::Object::Fields::Unknown->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'DB::Object::Fields::Unknown'->new('table', $self->table_object->name, 'error', $exception, 'field', $method) || die("$error, and I could not instantiate a new instance of the module DB::Object::Fields::Unknown: ", 'DB::Object::Fields::Unknown'->error)
MC/DC0%0/1
'DB::Object::Fields::Unknown'->new('table', $self->table_object->name, 'error', $exception, 'field', $method) || die("$error, and I could not instantiate a new instance of the module DB::Object::Fields::Unknown: ", 'DB::Object::Fields::Unknown'->error)
'DB::Object::Fields::Unknown'->new('table', $self->table_object->name, 'error', $exception, 'field', $method)
Truth table0%0/2
A
A= 'DB::Object::Fields::Unknown'->new('table', $self->table_object->name, 'error', $exception, 'field', $method)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | table => $self->table_object->name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | error => $exception, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | field => $method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | ) || die( "${error}, and I could not instantiate a new instance of the module DB::Object::Fields::Unknown: ", DB::Object::Fields::Unknown->error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | warn( "Table ", $self->table_object->name, " has no such field \"$method\".\n" ) if( $self->_is_warnings_enabled( 'DB::Object' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # return( $self->error( "Table ", $self->table_object->name, " has no such field \"$method\"." ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | #die( "Table ", $self->table_object->name, " has no such field \"$method\".\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | return( $unknown ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | sub FREEZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FREEZE: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | my $serialiser = CORE::shift( @_ ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift @_ // ""
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table0%0/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $class = CORE::ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # We keep a strict allow-list to avoid accidentally freezing DBI handles or other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # process-local state. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my @props = @{$self->{_fields}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | foreach my $prop ( @props ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if( CORE::exists( $self->{ $prop } ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $self->{$prop} and defined $self->{$prop} and ref $self->{$prop} ne "CODE"
exists $self->{$prop} and defined $self->{$prop}
MC/DC0%0/3
exists $self->{$prop} and defined $self->{$prop} and ref $self->{$prop} ne "CODE"
exists $self->{$prop}
defined $self->{$prop}
ref $self->{$prop} ne "CODE"
Truth table0%0/4
A and B and C
A= exists $self->{$prop}B= defined $self->{$prop}C= ref $self->{$prop} ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | defined( $self->{ $prop } ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | CORE::ref( $self->{ $prop } ) ne 'CODE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $hash->{ $prop } = $self->{ $prop }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # Return an array reference rather than a list so this works with Sereal and CBOR. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # Before Sereal version 4.023, Sereal did not support multiple values returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if( $serialiser eq 'Sereal' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | require Sereal::Encoder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | require version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if( version->parse( Sereal::Encoder->VERSION ) < version->parse( '4.023' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | CORE::return( [$class, $hash] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # But Storable wants a list with the first element being the serialised element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | CORE::return( $class, $hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub STORABLE_freeze { return( shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub STORABLE_thaw { return( shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | sub THAW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
THAW: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # STORABLE_thaw would issue $cloning as the 2nd argument, while CBOR would issue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # 'CBOR' as the second value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my( $self, undef, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1
ref $args[0] eq "ARRAY"
Truth table0%0/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref and ref $ref eq "ARRAY"
ref $self or $self
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref
ref $ref eq "ARRAY"
scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self
$self
Truth table0%0/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
Truth table0%0/3
A or B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # Storable pattern requires to modify the object it created rather than returning a new one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if( CORE::ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | foreach( CORE::keys( %$hash ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->{ $_ } = CORE::delete( $hash->{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $new = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $new = CORE::bless( $hash => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | CORE::return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||