| 1 | package Hades::Realm::Compiled::Params; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use base qw/Hades/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | our $VERSION = 0.03; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | sub new { | ||||||||||||||||||||||||||||
| 8 | 15 | ▶ | my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ ); | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | 15 | my $self = $cls->SUPER::new(%args); | |||||||||||||||||||||||||||
| 10 | 15 | my %accessors = ( cpo => { required => 1, default => [], }, ); | |||||||||||||||||||||||||||
| 11 | 15 | for my $accessor ( keys %accessors ) { | |||||||||||||||||||||||||||
| 12 | my $value | ||||||||||||||||||||||||||||
| 13 | = $self->$accessor( | ||||||||||||||||||||||||||||
| 14 | defined $args{$accessor} | ||||||||||||||||||||||||||||
| 15 | ? $args{$accessor} | ||||||||||||||||||||||||||||
| 16 | 15 | ▶ | : $accessors{$accessor}->{default} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 13 | ▶ | unless ( !$accessors{$accessor}->{required} || defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $accessors{$accessor}{"required"} or defined $value
MC/DC0%0/2
not $accessors{$accessor}{"required"} or defined $value
not $accessors{$accessor}{"required"}
defined $value
Truth table33%1/3
not(A) or B
A= not $accessors{$accessor}{"required"}B= defined $value
| |||||||||||||||||||||||||||||
| 18 | 0 | die "$accessor accessor is required"; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | 13 | return $self; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | sub cpo { | ||||||||||||||||||||||||||||
| 25 | 22 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
cpo: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 22 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 18 | ▶ | if ( ( ref($value) || "" ) ne "ARRAY" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
ref $value || ''
MC/DC100%1/1
ref $value || ''
ref $value
Truth table100%2/2
A
A= ref $value
| |||||||||||||||||||||||||||||
| 28 | 4 | die qq{ArrayRef: invalid value $value for accessor cpo}; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 14 | $self->{cpo} = $value; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 18 | return $self->{cpo}; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub push_cpo { | ||||||||||||||||||||||||||||
| 36 | 17 | ▶ | my ( $self, $key, $value ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
push_cpo: called CC=7 SCAR=19.8
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 17 | ▶ | if ( !defined($key) || ref $key ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $key or ref $key
MC/DC50%1/2
not defined $key or ref $key
not defined $key
ref $key
Truth table66%2/3
not(A) or B
A= not defined $keyB= ref $key
| |||||||||||||||||||||||||||||
| 38 | 2 | ▶ | $key = defined $key ? $key : 'undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 2 | die qq{Str: invalid value $key for variable \$key in method push_cpo}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 15 | ▶ | if ( !defined($value) || ref $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $value or ref $value
MC/DC50%1/2
not defined $value or ref $value
not defined $value
ref $value
Truth table66%2/3
not(A) or B
A= not defined $valueB= ref $value
| |||||||||||||||||||||||||||||
| 42 | 2 | ▶ | $value = defined $value ? $value : 'undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 2 | die | |||||||||||||||||||||||||||
| 44 | qq{Str: invalid value $value for variable \$value in method push_cpo}; | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | 13 | push @{ $self->{cpo} }, qq|$key => $value|; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub build_accessor { | ||||||||||||||||||||||||||||
| 50 | 11 | ▶ | my ( $orig, $self, @params ) = ( 'SUPER::build_accessor', @_ ); | ||||||||||||||||||||||||||
|
Subroutine
build_accessor: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | $params[2]->{ $params[1] }->{type}->[0] =~ s/\s*\[/[/g | ||||||||||||||||||||||||||||
| 52 | 11 | ▶ | if $params[2]->{ $params[1] }->{type}->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | $self->push_cpo( $params[1], | ||||||||||||||||||||||||||||
| 54 | '[' . ( $params[2]->{ $params[1] }->{type}->[0] || 'Any' ) | ||||||||||||||||||||||||||||
| 55 | . ($params[2]->{ $params[1] }->{default} | ||||||||||||||||||||||||||||
| 56 | 11 | ▶ | ? ', { default => ' . $params[2]->{ $params[1] }->{default} . '} ]' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$params[2]{$params[1]}{'type'}[0] || 'Any'
MC/DC100%1/1
$params[2]{$params[1]}{'type'}[0] || 'Any'
$params[2]{$params[1]}{'type'}[0]
Truth table100%2/2
A
A= $params[2]{$params[1]}{'type'}[0]
| |||||||||||||||||||||||||||||
| 57 | : ']' | ||||||||||||||||||||||||||||
| 58 | ) | ||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||
| 60 | 11 | my @res = $self->$orig(@params); | |||||||||||||||||||||||||||
| 61 | 11 | ▶ | return wantarray ? @res : $res[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub build_sub { | ||||||||||||||||||||||||||||
| 65 | 8 | ▶ | my ( $self, $mg, $name, $meta ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
build_sub: called CC=16 SCAR=28.3
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | 8 | ▶ | if ( !ref $mg ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 2 | ▶ | $mg = defined $mg ? $mg : 'undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 2 | die qq{Ref: invalid value $mg for variable \$mg in method build_}; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 6 | ▶ | if ( !defined($name) || ref $name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $name or ref $name
MC/DC50%1/2
not defined $name or ref $name
not defined $name
ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
| |||||||||||||||||||||||||||||
| 71 | 2 | ▶ | $name = defined $name ? $name : 'undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 2 | die | |||||||||||||||||||||||||||
| 73 | qq{Str: invalid value $name for variable \$name in method build_sub}; | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 4 | ▶ | if ( ( ref($meta) || "" ) ne "HASH" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
ref $meta || ''
MC/DC100%1/1
ref $meta || ''
ref $meta
Truth table100%2/2
A
A= ref $meta
| |||||||||||||||||||||||||||||
| 76 | 2 | ▶ | $meta = defined $meta ? $meta : 'undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 2 | die | |||||||||||||||||||||||||||
| 78 | qq{HashRef: invalid value $meta for variable \$meta in method build_sub}; | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 2 | my $code = $meta->{$name}->{code}; | |||||||||||||||||||||||||||
| 81 | 2 | my ( $params, $types, $params_explanation, $private ); | |||||||||||||||||||||||||||
| 82 | 2 | ▶ | $private = $self->build_private($name) if $meta->{$name}->{private}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 2 | ▶ | if ( $meta->{$name}->{param} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 2 | for my $param ( @{ $meta->{$name}->{param} } ) { | |||||||||||||||||||||||||||
| 85 | 2 | ▶ | $params_explanation .= ', ' if $params_explanation; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 2 | $params .= ', ' . $param; | |||||||||||||||||||||||||||
| 87 | 2 | my $pm = $meta->{$name}->{params_map}->{$param}; | |||||||||||||||||||||||||||
| 88 | 2 | ▶ | $pm->{type} ||= q|Any|; | ||||||||||||||||||||||||||
|
Condition50%1/2
$pm->{"type"} ||= "Any"
MC/DC0%0/1
$pm->{"type"} ||= "Any"
$pm->{"type"}
Truth table50%1/2
A
A= $pm->{"type"}
| |||||||||||||||||||||||||||||
| 89 | 2 | ▶ | my $t = $pm->{type} . ($pm->{default} ? ', { default => ' . $pm->{default} . ' }' : ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 2 | ▶ | $types .= $types ? ', ' . $t : $t; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 2 | $params_explanation .= qq|param $param to be a $pm-> { type } |; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | 2 | my $type = $self->build_type( $name, $types, $types ); | |||||||||||||||||||||||||||
| 94 | 2 | $self->push_cpo( $name, '[' . $types . ']' ); | |||||||||||||||||||||||||||
| 95 | 2 | $code = qq| { my (\$self $params) = (shift$type); $code; } |; | |||||||||||||||||||||||||||
| 96 | 2 | $params =~ s/^\,\s*//; | |||||||||||||||||||||||||||
| 97 | 2 | my $example = qq|\$obj->$name($params)|; | |||||||||||||||||||||||||||
| 98 | $mg->sub($name)->code($code) | ||||||||||||||||||||||||||||
| 99 | ->pod(qq|call $name method. Expects $params_explanation.|) | ||||||||||||||||||||||||||||
| 100 | ->example($example) | ||||||||||||||||||||||||||||
| 101 | 2 | ->test( $self->build_tests( $name, $meta->{$name} ) ); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | sub build_type { | ||||||||||||||||||||||||||||
| 106 | 19 | ▶ | my ( $self, $name, $type, $value ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
build_type: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 19 | ▶ | if ( !defined($name) || ref $name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $name or ref $name
MC/DC50%1/2
not defined $name or ref $name
not defined $name
ref $name
Truth table66%2/3
not(A) or B
A= not defined $nameB= ref $name
| |||||||||||||||||||||||||||||
| 108 | 2 | ▶ | $name = defined $name ? $name : 'undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 2 | die | |||||||||||||||||||||||||||
| 110 | qq{Str: invalid value $name for variable \$name in method build_type}; | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 17 | ▶ | if ( defined $type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 14 | ▶ | if ( ref $type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 2 | die | |||||||||||||||||||||||||||
| 115 | qq{Optional[Str]: invalid value $type for variable \$type in method build_type}; | ||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | 15 | ▶ | if ( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 4 | ▶ | if ( ref $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 2 | die | |||||||||||||||||||||||||||
| 121 | qq{Optional[Str]: invalid value $value for variable \$value in method build_type}; | ||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | 13 | my $code = ''; | |||||||||||||||||||||||||||
| 125 | 13 | ▶ | if ($type) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 12 | ▶ | $code | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | .= $value | ||||||||||||||||||||||||||||
| 128 | ? qq|, \$VALIDATE->$name->(\@_)| | ||||||||||||||||||||||||||||
| 129 | : qq|(\$value) = \$VALIDATE->$name->(\$value);|; | ||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 13 | return $code; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | sub after_class { | ||||||||||||||||||||||||||||
| 135 | 4 | ▶ | my ( $self, $mg ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
after_class: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||
| 136 | 4 | ▶ | if ( ( ref($mg) || "" ) =~ m/^(|HASH|ARRAY|SCALAR|CODE|GLOB)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
ref $mg || ''
MC/DC100%1/1
ref $mg || ''
ref $mg
Truth table100%2/2
A
A= ref $mg
| |||||||||||||||||||||||||||||
| 137 | 2 | ▶ | $mg = defined $mg ? $mg : 'undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 2 | die | |||||||||||||||||||||||||||
| 139 | qq{Object: invalid value $mg for variable \$mg in method after_class}; | ||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | 2 | my $cpo = join ', ', @{ $self->cpo }; | |||||||||||||||||||||||||||
| 142 | 2 | $mg->use(q|Types::Standard qw/Any Item Bool Str Num Int Ref ScalarRef ArrayRef HashRef CodeRef RegexpRef GlobRef Object Map Tuple Dict Optional/|); | |||||||||||||||||||||||||||
| 143 | 2 | $mg->use(q|Compiled::Params::OO|); | |||||||||||||||||||||||||||
| 144 | 2 | $mg->our(q|$VALIDATE|); | |||||||||||||||||||||||||||
| 145 | 2 | my $code = qq|\$VALIDATE = Compiled::Params::OO::cpo( $cpo );|; | |||||||||||||||||||||||||||
| 146 | 2 | my %class = %Module::Generate::CLASS; | |||||||||||||||||||||||||||
| 147 | 2 | ▶ | if ( $class{CURRENT}{BEGIN} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | ( my $begin = $class{CURRENT}{BEGIN} ) =~ s/\s*\}\s*$//; | |||||||||||||||||||||||||||
| 149 | 0 | $code = $begin . $code . "\}"; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | 2 | else { $code = qq|{ $code }|; } | |||||||||||||||||||||||||||
| 152 | 2 | $class{CURRENT}{BEGIN} = $code; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 4 | 1; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | __END__ | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head1 NAME | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | Hades::Realm::Compiled::Params - The great new Hades::Realm::Compiled::Params! | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | =head1 VERSION | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | Version 0.03 | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =cut | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | use Hades::Realm::Compiled::Params; | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | Hades::Realm::Compiled::Params->run({ | ||||||||||||||||||||||||||||
| 174 | eval => q| | ||||||||||||||||||||||||||||
| 175 | Kosmos { | ||||||||||||||||||||||||||||
| 176 | penthos :d(2) :p :pr :c :t(Int) | ||||||||||||||||||||||||||||
| 177 | curae :r :t(Any) | ||||||||||||||||||||||||||||
| 178 | geras $nosoi :t(Int) { | ||||||||||||||||||||||||||||
| 179 | if ($self->penthos == $nosoi) { | ||||||||||||||||||||||||||||
| 180 | return $self->curae; | ||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |, | ||||||||||||||||||||||||||||
| 185 | lib => 't/lib' | ||||||||||||||||||||||||||||
| 186 | }); | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | ... generates ... | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | package Kosmos; | ||||||||||||||||||||||||||||
| 191 | use strict; | ||||||||||||||||||||||||||||
| 192 | use warnings; | ||||||||||||||||||||||||||||
| 193 | use Types::Standard qw/Str Optional HashRef Tuple Map Dict ArrayRef Int Any/; | ||||||||||||||||||||||||||||
| 194 | use Compiled::Params::OO; | ||||||||||||||||||||||||||||
| 195 | our $VERSION = 0.01; | ||||||||||||||||||||||||||||
| 196 | our $VALIDATE; | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | BEGIN { | ||||||||||||||||||||||||||||
| 199 | $VALIDATE = Compiled::Params::OO::cpo( | ||||||||||||||||||||||||||||
| 200 | penthos => [ Int, { default => 2 } ], | ||||||||||||||||||||||||||||
| 201 | curae => [ Any ], | ||||||||||||||||||||||||||||
| 202 | geras => [ Int, { default => 2 } ] | ||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | sub new { | ||||||||||||||||||||||||||||
| 207 | my ( $cls, %args ) = ( shift(), scalar @_ == 1 ? %{ $_[0] } : @_ ); | ||||||||||||||||||||||||||||
| 208 | my $self = bless {}, $cls; | ||||||||||||||||||||||||||||
| 209 | my %accessors | ||||||||||||||||||||||||||||
| 210 | = ( curae => { required => 1, }, penthos => { default => 2, }, ); | ||||||||||||||||||||||||||||
| 211 | for my $accessor ( keys %accessors ) { | ||||||||||||||||||||||||||||
| 212 | my $value | ||||||||||||||||||||||||||||
| 213 | = $self->$accessor( | ||||||||||||||||||||||||||||
| 214 | defined $args{$accessor} | ||||||||||||||||||||||||||||
| 215 | ? $args{$accessor} | ||||||||||||||||||||||||||||
| 216 | : $accessors{$accessor}->{default} ); | ||||||||||||||||||||||||||||
| 217 | unless ( !$accessors{$accessor}->{required} || defined $value ) { | ||||||||||||||||||||||||||||
| 218 | die "$accessor accessor is required"; | ||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | return $self; | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | sub penthos { | ||||||||||||||||||||||||||||
| 225 | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||
| 226 | my $private_caller = caller(); | ||||||||||||||||||||||||||||
| 227 | if ( $private_caller ne __PACKAGE__ ) { | ||||||||||||||||||||||||||||
| 228 | die "cannot call private method penthos from $private_caller"; | ||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | if ( defined $value ) { | ||||||||||||||||||||||||||||
| 231 | ($value) = $VALIDATE->penthos->($value); | ||||||||||||||||||||||||||||
| 232 | $self->{penthos} = $value; | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | return $self->{penthos}; | ||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | sub clear_penthos { | ||||||||||||||||||||||||||||
| 238 | my ($self) = @_; | ||||||||||||||||||||||||||||
| 239 | delete $self->{penthos}; | ||||||||||||||||||||||||||||
| 240 | return $self; | ||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | sub has_penthos { | ||||||||||||||||||||||||||||
| 244 | my ($self) = @_; | ||||||||||||||||||||||||||||
| 245 | return exists $self->{penthos}; | ||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | sub curae { | ||||||||||||||||||||||||||||
| 249 | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||
| 250 | if ( defined $value ) { | ||||||||||||||||||||||||||||
| 251 | ($value) = $VALIDATE->curae->($value); | ||||||||||||||||||||||||||||
| 252 | $self->{curae} = $value; | ||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | return $self->{curae}; | ||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | sub geras { | ||||||||||||||||||||||||||||
| 258 | my ( $self, $nosoi ) = ( shift, $VALIDATE->geras->(@_) ); | ||||||||||||||||||||||||||||
| 259 | if ( $self->penthos == $nosoi ) { return $self->curae; } | ||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =head2 new | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | Instantiate a new Hades::Realm::Compiled::Params object. | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | Hades::Realm::Compiled::Params->new | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | =head2 push_cpo | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | call push_cpo method. Expects param $key to be a Str, param $value to be a Str. | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | $obj->push_cpo($key, $value) | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =head2 build_accessor | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | call build_accessor method. | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | =head2 build_sub | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | call build_sub method. Expects param $mg to be a Ref, param $name to be a Str, param $meta to be a HashRef. | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | $obj->build_sub($mg, $name, $meta) | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | =head2 build_type | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | call build_type method. Expects param $name to be a Str, param $type to be a Optional[Str], param $value to be a Optional[Str]. | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | $obj->build_type($name, $type, $value) | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =head2 after_class | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | call after_class method. Expects param $mg to be a Object. | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | $obj->after_class($mg) | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | =head1 ACCESSORS | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | =head2 cpo | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | get or set cpo. | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | $obj->cpo; | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | $obj->cpo($value); | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | LNATION, C<< <email at lnation.org> >> | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | =head1 BUGS | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | Please report any bugs or feature requests to C<bug-hadesrealmcompiledparams at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 315 | the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hades-Realm-Compiled-Params>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 316 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | perldoc Hades::Realm::Compiled::Params | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | You can also look for information at: | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =over 4 | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Hades-Realm-Compiled-Params> | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | L<http://annocpan.org/dist/Hades-Realm-Compiled-Params> | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | L<https://cpanratings.perl.org/d/Hades-Realm-Compiled-Params> | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | L<https://metacpan.org/release/Hades-Realm-Compiled-Params> | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | =back | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | This software is Copyright (c) 2020 by LNATION. | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | This is free software, licensed under: | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =cut | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||