| 1 | package DBIx::Class::InflateColumn::ClassTypeEnum; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Inflate enum-like columns to your Class::Type::Enum classes | ||||||||||||||||||||||||||||
| 3 | 1 | $DBIx::Class::InflateColumn::ClassTypeEnum::VERSION = '0.014'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub register_column { | ||||||||||||||||||||||||||
|
Subroutine
register_column: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 0 | my ($self, $column, $info) = @_; | |||||||||||||||||||||||||||
| 14 | 0 | $self->next::method($column, $info); | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | return unless $info->{extra} and my $class = $info->{extra}{enum_class}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$info->{"extra"} and my $class = $info->{"extra"}{"enum_class"}
MC/DC0%0/2
$info->{"extra"} and my $class = $info->{"extra"}{"enum_class"}
$info->{"extra"}
my $class = $info->{"extra"}{"enum_class"}
Truth table0%0/3
A and B
A= $info->{"extra"}B= my $class = $info->{"extra"}{"enum_class"}
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | unless (eval { $class->isa('Class::Type::Enum') }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 0 | Carp::croak "enum_class $class is not loaded or doesn't inherit from Class::Type::Enum"; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # I'd love to DTRT based on the column type but I think they're practically | ||||||||||||||||||||||||||||
| 23 | # freeform in DBIC and just match the DB types, so that's a lot of | ||||||||||||||||||||||||||||
| 24 | # possibilities... | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if ($info->{extra}{enum_ordinal_storage}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | $self->inflate_column( | ||||||||||||||||||||||||||||
| 28 | $column => { | ||||||||||||||||||||||||||||
| 29 | 0 | ▶ | inflate => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 30 | 0 | my ($ord) = @_; | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | return unless defined $ord; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | $class->inflate_ordinal($ord); | |||||||||||||||||||||||||||
| 33 | }, | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | deflate => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 35 | 0 | my ($enum) = @_; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | return unless defined $enum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | $enum->numify; | |||||||||||||||||||||||||||
| 38 | }, | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 0 | ); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | else { | ||||||||||||||||||||||||||||
| 44 | $self->inflate_column( | ||||||||||||||||||||||||||||
| 45 | $column => { | ||||||||||||||||||||||||||||
| 46 | 0 | ▶ | inflate => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 47 | 0 | my ($val) = @_; | |||||||||||||||||||||||||||
| 48 | 0 | ▶ | return unless defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | $class->inflate_symbol($val); | |||||||||||||||||||||||||||
| 50 | }, | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | deflate => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 52 | 0 | my ($enum) = @_; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | return unless defined $enum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | $enum->stringify; | |||||||||||||||||||||||||||
| 55 | }, | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 0 | ); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | 1; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||