X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=samples%2Fapp%2Fapp1%2Flib%2FApp1%2FPickDomainAlternate.pm;fp=samples%2Fapp%2Fapp1%2Flib%2FApp1%2FPickDomainAlternate.pm;h=750882efcb773dd5661b666787f48adc29238db1;hp=0000000000000000000000000000000000000000;hb=ed00221d27dfab1e82ec2ea040ab4c399a91c545;hpb=0b04f67c06c1db11969096f07dfc7dbb23bf99ba diff --git a/samples/app/app1/lib/App1/PickDomainAlternate.pm b/samples/app/app1/lib/App1/PickDomainAlternate.pm new file mode 100644 index 0000000..750882e --- /dev/null +++ b/samples/app/app1/lib/App1/PickDomainAlternate.pm @@ -0,0 +1,35 @@ +package App1::PickDomainAlternate; + +=head1 NAME + +App1::PickDomainAlternate - pick from a list of generated alternates when pick_domain fails + +=cut + +use strict; +use warnings; +use base qw(App1); + +sub skip { return 1 if shift->stash->{'domain_available'} } + +sub hash_swap { + my $self = shift; + return $self->{'pda_hash_swap'} ||= do { # cache since hash_fill is using us also + my $dom = $self->stash->{'domain_prefix'} || die "Missing domain_prefix"; + + my @domains = map {"$dom.$_"} qw(net org biz info us); # contrived availability check + my $hash = {domains => \@domains}; + }; +} + +sub hash_fill { + my $self = shift; + my $doms = $self->hash_swap->{'domains'}; + return { + domain => $doms->[1], # promote .org #[rand @$doms], + }; +} + +sub info_complete { 0 } # step always shows when called + +1;