| 1 | package MooseX::ShortHas; | ||
| 2 | |||
| 3 | 3 | ▶ | use strictures 2; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 3 | our $VERSION = '1.222491'; # VERSION | |
| 6 | |||
| 7 | # ABSTRACT: shortcuts for common Moose has attribute configurations | ||
| 8 | |||
| 9 | # | ||
| 10 | # This file is part of MooseX-ShortHas | ||
| 11 | # | ||
| 12 | # | ||
| 13 | # Christian Walde has dedicated the work to the Commons by waiving all of his | ||
| 14 | # or her rights to the work worldwide under copyright law and all related or | ||
| 15 | # neighboring legal rights he or she had in the work, to the extent allowable by | ||
| 16 | # law. | ||
| 17 | # | ||
| 18 | # Works under CC0 do not require attribution. When citing the work, you should | ||
| 19 | # not imply endorsement by the author. | ||
| 20 | # | ||
| 21 | |||
| 22 | |||
| 23 | 3 | ▶ | use Moose::Exporter; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 3 | ▶ | use Sub::Install 'install_sub'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | 3 | ▶ | use MooseX::AttributeShortcuts (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | |||
| 27 | 12 | ▶ | sub _modified_has { |
|
Subroutine
_modified_has: called CC=1 SCAR=0.0
| |||
| 28 | 12 | my ($mods) = @_; | |
| 29 | 8 | ▶ | sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 30 | 8 | @_ = ( shift, shift, @{$mods}, @_ ); | |
| 31 | 8 | goto &Moose::has; | |
| 32 | 12 | }; | |
| 33 | } | ||
| 34 | |||
| 35 | 3 | my %mods = ( | |
| 36 | lazy => [ is => "lazy", builder => ], | ||
| 37 | map +( $_ => [ is => $_, required => 1 ] ), qw( ro rwp rw ), | ||
| 38 | ); | ||
| 39 | install_sub { into => __PACKAGE__, as => $_, code => _modified_has $mods{$_} } | ||
| 40 | 3 | for keys %mods; | |
| 41 | |||
| 42 | 3 | Moose::Exporter->setup_import_methods # | |
| 43 | ( with_meta => [ keys %mods ], also => "MooseX::AttributeShortcuts" ); | ||
| 44 | |||
| 45 | 3 | 1; | |
| 46 | |||
| 47 | __END__ | ||