-
-
16 Jun 2022 14:03:01 UTC
- Distribution: MooseX-Extended
- Module version: 0.25
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (155 / 0 / 18)
- Kwalitee
Bus factor: 1- % Coverage
- License: artistic_2
- Perl: v5.20.0
- Activity
24 month- Tools
- Download (48.77KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- B::Hooks::AtRuntime
- Carp
- Data::Printer
- Exporter
- Import::Into
- Module::Load
- Moose
- Moose::Exception
- Moose::Exception::Role::Class
- Moose::Exporter
- Moose::Meta::Role
- Moose::Role
- Moose::Util
- MooseX::Role::WarnOnConflict
- MooseX::StrictConstructor
- Perl::Critic::Policy::Moose::ProhibitMultipleWiths
- Perl::Critic::Policy::Moose::RequireMakeImmutable
- Ref::Util
- Storable
- Type::Library
- Type::Params
- Type::Tiny
- Type::Utils
- Types::Common::Numeric
- Types::Common::String
- Types::Standard
- feature
- mro
- namespace::autoclean
- parent
- strict
- true
- warnings
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
MooseX::Extended::Custom - Build a custom Moose, just for you.
VERSION
version 0.25
SYNOPSIS
Define your own version of 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) { ... } }
DESCRIPTION
I hate boilerplate, so let's get rid of it. Let's say you don't want namespace::autoclean or
carp
, but you do wantmulti
. Plus, you have custom versions ofcarp
andcroak
:package Some::Class { use MooseX::Extended excludes => [qw/ autoclean carp /], includes => ['multi']; use My::Carp q(carp croak); ... my code here }
You probably get tired of typing that every time. Now you don't have to.
package My::Moose { use MooseX::Extended::Custom; use My::Carp (); use Import::Into; sub import { my ( $class, %args ) = @_; my $target_class = caller; MooseX::Extended::Custom->create( excludes => [qw/ autoclean carp /], includes => ['multi'], %args # you need this to allow customization of your customization ); My::Carp->import::into($target_class, qw(carp croak)); } }
And then when you use
My::Moose
, that's all set up for you.If you need to change this on a "per class" basis:
use My::Moose excludes => ['carp'], types => [qw/ArrayRef Num/];
The above changes your
excludes
and addstypes
, but doesn't change yourincludes
.AUTHOR
Curtis "Ovid" Poe <curtis.poe@gmail.com>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2022 by Curtis "Ovid" Poe.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
Module Install Instructions
To install MooseX::Extended, copy and paste the appropriate command in to your terminal.
cpanm MooseX::Extended
perl -MCPAN -e shell install MooseX::Extended
For more information on module installation, please visit the detailed CPAN module installation guide.