MooseX-Extended
view release on metacpan or search on metacpan
lib/MooseX/Extended/Custom.pm view on Meta::CPAN
package MooseX::Extended::Custom;
# ABSTRACT: Build a custom Moose, just for you.
use 5.20.0;
use strict;
use warnings;
use true;
use MooseX::Extended::Core qw(
_enabled_features
_disabled_warnings
);
use MooseX::Extended ();
use namespace::autoclean;
our $VERSION = '0.35';
sub import {
my @caller = caller(0);
my $custom_moose = $caller[0]; # this is our custom Moose definition
true->import::into($custom_moose) unless $caller[1] =~ /^\(eval/;
strict->import::into($custom_moose);
warnings->import::into($custom_moose);
namespace::autoclean->import::into($custom_moose);
feature->import( _enabled_features() );
warnings->unimport(_disabled_warnings);
}
sub create {
my ( $class, %args ) = @_;
my $target_class = caller(1); # this is the class consuming our custom Moose
MooseX::Extended->import(
%args,
call_level => 1,
for_class => $target_class,
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
MooseX::Extended::Custom - Build a custom Moose, just for you.
=head1 VERSION
version 0.35
=head1 SYNOPSIS
Define your own version of L<MooseX::Extended>:
package My::Moose {
use MooseX::Extended::Custom;
sub import {
my ( $class, %args ) = @_;
MooseX::Extended::Custom->create(
excludes => [qw/ StrictConstructor c3 /],
includes => ['multi'],
%args # you need this to allow customization of your customization
);
}
}
# no need for a true value
And then use it:
package Some::Class {
use My::Moose types => [qw/ArrayRef Num/];
param numbers ( isa => ArrayRef[Num] );
multi sub foo ($self) { ... }
multi sub foo ($self, $bar) { ... }
( run in 2.193 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )