MooX-Press
view release on metacpan or search on metacpan
lib/MooX/Press.pm view on Meta::CPAN
use 5.008008;
use strict;
use warnings;
package MooX::Press;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.086';
use Types::Standard 1.010000 -is, -types;
use Types::TypeTiny qw(ArrayLike HashLike);
use Type::Registry ();
use Exporter::Tiny qw(mkopt);
use Import::Into;
use match::simple qw(match);
use Module::Runtime qw(use_module);
use namespace::autoclean;
sub make_absolute_package_name {
my $p = shift;
$] lt '5.018' ? "main::$p" : "::$p";
}
if ( $] lt '5.010' ) {
require UNIVERSAL::DOES;
}
# Options not to carry up into subclasses;
# mostly because subclasses inherit behaviour anyway.
my @delete_keys = qw(
subclass
has
with
extends
overload
factory
coerce
around
before
after
type_name
can
type_library_can
factory_package_can
abstract
multimethod
symmethod
multifactory
);
my $_handle_list = sub {
my ($thing) = @_;
return ()
unless defined $thing;
return $thing
if is_Str $thing;
return %$thing
if is_HashRef $thing;
return @$thing
if is_ArrayRef $thing;
goto $thing
if is_CodeRef $thing;
die "Unexepcted thing; got $thing";
};
my $_handle_list_add_nulls = sub {
my ($thing) = @_;
return map @$_, @{mkopt $thing}
if is_ArrayRef $thing;
goto $_handle_list;
};
my %_cached_moo_helper;
sub _apply_default_options {
my $builder = shift;
my $opts = $_[0];
$opts->{default_is} ||= 'ro';
$opts->{toolkit} ||= $ENV{'PERL_MOOX_PRESS_TOOLKIT'} || 'Moo';
$opts->{version} = $opts->{caller}->VERSION
unless exists $opts->{version};
( run in 2.052 seconds using v1.01-cache-2.11-cpan-800906f7e73 )