COPYRIGHT000644001750001750 332213412643246 14527 0ustar00taitai000000000000MooseX-MungeHas-0.011Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: MooseX-MungeHas Upstream-Contact: Toby Inkster (TOBYINK) Source: https://metacpan.org/release/MooseX-MungeHas Files: examples/relax-type-constraints.pl t/01basic.t t/02moose.t t/03moo.t t/04mouse.t Copyright: This software is copyright (c) 2013 by Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: Changes META.json META.yml doap.ttl Copyright: Copyright 2019 Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: COPYRIGHT CREDITS SIGNATURE Copyright: None License: public-domain Files: INSTALL LICENSE Makefile.PL Copyright: Unknown License: Unknown Files: README lib/MooseX/MungeHas.pm Copyright: This software is copyright (c) 2013-2014, 2017 by Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: t/08rolebuildersub.t t/09undefbare.t Copyright: This software is copyright (c) 2017 by Aaron Crane. License: GPL-1.0+ or Artistic-1.0 Files: t/06multiattr.t Copyright: This software is copyright (c) 2017 by Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: t/07lazy.t Copyright: Copyright 2018 Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: dist.ini Copyright: Copyright 2013 Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: t/05multihas.t Copyright: This software is copyright (c) 2014 by Toby Inkster. License: GPL-1.0+ or Artistic-1.0 License: Artistic-1.0 This software is Copyright (c) 2019 by the copyright holder(s). This is free software, licensed under: The Artistic License 1.0 License: GPL-1.0 This software is Copyright (c) 2019 by the copyright holder(s). This is free software, licensed under: The GNU General Public License, Version 1, February 1989 CREDITS000644001750001750 30313412643246 14230 0ustar00taitai000000000000MooseX-MungeHas-0.011Maintainer: - Toby Inkster (TOBYINK) Contributor: - Aaron Crane (ARC) - Andrew Rodland (ARODLAND) Thanks: - Luc J. Bourhis - Pierre Masci Changes000644001750001750 556013412643246 14535 0ustar00taitai000000000000MooseX-MungeHas-0.011MooseX-MungeHas =============== Created: 2013-05-27 Home page: Bug tracker: Maintainer: Toby Inkster (TOBYINK) 0.011 2019-01-01 - Added: Add always_required feature. 0.010 2018-07-28 [ Bug Fixes ] - Eliminate uninitialized warning when no `is` under Moose. Aaron Crane++ [ Test Suite ] - Make 07lazy.t actually test something useful. I can't remember why this test case even exists. 0.009 2018-07-28 [ Bug Fixes ] - Don't use fully-qualified sub names for builders. Aaron Crane++ 0.008 2017-05-27 [ Bug Fixes ] - Make sure that has(\@attr, %spec) works. Fixes RT#121895. 0.007 2014-09-09 - Allow exporting of more than one `has` function. - Better detection of OO framework. - Bugfix for interaction of `is_rw` and `has $name=>$builder`. 0.006 2014-09-09 tobyink ♥ builder - Allow Moo-style `builder=>$coderef` in Moose and Mouse. - Allow Object::Simple-style `has $name=>$coderef` in Moo, Moose, and Mouse. - Allow `has $name=>$type` in Moo, Moose, and Mouse. 0.005 2014-02-14 tobyink ♥ isa [ Bug Fixes ] - s/find_or_parse_type_constraint/find_or_create_isa_type_constraint/ Fixes RT#92557. Pierre Masci++ [ Documentation ] - Various documentation improvements. [ Test Suite ] - No longer depend on Types::Standard for tests; skip those tests if it's not installed. [ Packaging ] - No longer depend on Eval::TypeTiny. [ Other ] - Allow Moo-style isa=>sub{...} in Moose and Mouse. - Always enable the eq_1 feature; it's never useful for it to be disabled. - Remove the absolute dependency on Eval::TypeTiny; allow Eval::Closure to be used in its stead. 0.004 2013-08-29 [ Bug Fixes ] - Fix a stray `$.` that wasn't changed in 0.003. Andrew Rodland++ 0.003 2013-08-28 - Use the `$_` variable for the attribute name instead of `$.`. - Use the `%_` hash for the attribute spec instead of `%$_`. 0.002 2013-08-20 [ Bug Fixes ] - Fix syntax error compiling the eq_1 munger. 0.001 2013-06-12 [ Documentation ] - examples/relax-type-constraints.pl 0.000_04 2013-05-31 [ Bug Fixes ] - local @_ doesn't work with goto in Perl < 5.18. (Only affects Mouse.) Luc J. Bourhis++ 0.000_03 2013-05-31 [ Bug Fixes ] - Fix weird overloading-related bug in Perl < 5.17. 0.000_02 2013-05-31 [ Packaging ] - Depend on newer version of Eval::TypeTiny. - Much improved test suite. [ Other ] - Added: Make coerce => 0|1 work in Moo. - Removed: Drop the idea of shortcutting import with a single coderef; it doesn't work out so well. 0.000_01 2013-05-27 Preview release INSTALL000644001750001750 171113412643246 14265 0ustar00taitai000000000000MooseX-MungeHas-0.011 Installing MooseX-MungeHas should be straightforward. INSTALLATION WITH CPANMINUS If you have cpanm, you only need one line: % cpanm MooseX::MungeHas If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S MooseX::MungeHas INSTALLATION WITH THE CPAN SHELL Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan MooseX::MungeHas MANUAL INSTALLATION As a last resort, you can manually install it. Download the tarball and unpack it. Consult the file META.json for a list of pre-requisites. Install these first. To build MooseX-MungeHas: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install LICENSE000644001750001750 4365513412643246 14276 0ustar00taitai000000000000MooseX-MungeHas-0.011This software is copyright (c) 2019 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2019 by Toby Inkster. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2019 by Toby Inkster. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End MANIFEST000644001750001750 45413412643246 14350 0ustar00taitai000000000000MooseX-MungeHas-0.011COPYRIGHT CREDITS Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README SIGNATURE dist.ini doap.ttl examples/relax-type-constraints.pl lib/MooseX/MungeHas.pm t/01basic.t t/02moose.t t/03moo.t t/04mouse.t t/05multihas.t t/06multiattr.t t/07lazy.t t/08rolebuildersub.t t/09undefbare.t META.json000644001750001750 464413412643246 14665 0ustar00taitai000000000000MooseX-MungeHas-0.011{ "abstract" : "munge your \"has\" (works with Moo, Moose and Mouse)", "author" : [ "Toby Inkster (TOBYINK) " ], "dynamic_config" : 1, "generated_by" : "Dist::Inkt::Profile::TOBYINK version 0.024, CPAN::Meta::Converter version 2.150010", "keywords" : [], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "MooseX-MungeHas", "no_index" : { "directory" : [ "eg", "examples", "inc", "t", "xt" ] }, "optional_features" : {}, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.17" } }, "develop" : { "recommends" : { "Dist::Inkt" : "0" } }, "runtime" : { "requires" : { "Sub::Util" : "1.40", "perl" : "5.008000" }, "suggests" : { "Class::Tiny::Antlers" : "0", "Moo" : "1.002000", "Moose" : "2.0000", "Mouse" : "1.00" } }, "test" : { "recommends" : { "Moo" : "1.002000", "Moose" : "2.0000", "Types::Standard" : "0.006" }, "requires" : { "Test::Fatal" : "0", "Test::More" : "0.96", "Test::Requires" : "0.06" }, "suggests" : { "Mouse" : "1.00" } } }, "provides" : { "MooseX::MungeHas" : { "file" : "lib/MooseX/MungeHas.pm", "version" : "0.011" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "http://rt.cpan.org/Dist/Display.html?Queue=MooseX-MungeHas" }, "homepage" : "https://metacpan.org/release/MooseX-MungeHas", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "git://github.com/tobyink/p5-moosex-mungehas.git", "web" : "https://github.com/tobyink/p5-moosex-mungehas" }, "x_identifier" : "http://purl.org/NET/cpan-uri/dist/MooseX-MungeHas/project" }, "version" : "0.011", "x_contributors" : [ "Andrew Rodland (ARODLAND) ", "Aaron Crane (ARC) " ], "x_serialization_backend" : "JSON::PP version 2.27400_02" } META.yml000644001750001750 232613412643246 14510 0ustar00taitai000000000000MooseX-MungeHas-0.011--- abstract: 'munge your "has" (works with Moo, Moose and Mouse)' author: - 'Toby Inkster (TOBYINK) ' build_requires: Test::Fatal: '0' Test::More: '0.96' Test::Requires: '0.06' configure_requires: ExtUtils::MakeMaker: '6.17' dynamic_config: 1 generated_by: 'Dist::Inkt::Profile::TOBYINK version 0.024, CPAN::Meta::Converter version 2.150010' keywords: [] license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MooseX-MungeHas no_index: directory: - eg - examples - inc - t - xt optional_features: {} provides: MooseX::MungeHas: file: lib/MooseX/MungeHas.pm version: '0.011' requires: Sub::Util: '1.40' perl: '5.008000' resources: Identifier: http://purl.org/NET/cpan-uri/dist/MooseX-MungeHas/project bugtracker: http://rt.cpan.org/Dist/Display.html?Queue=MooseX-MungeHas homepage: https://metacpan.org/release/MooseX-MungeHas license: http://dev.perl.org/licenses/ repository: git://github.com/tobyink/p5-moosex-mungehas.git version: '0.011' x_contributors: - 'Andrew Rodland (ARODLAND) ' - 'Aaron Crane (ARC) ' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Makefile.PL000644001750001750 1357413412643246 15240 0ustar00taitai000000000000MooseX-MungeHas-0.011use strict; use ExtUtils::MakeMaker 6.17; my $EUMM = eval( $ExtUtils::MakeMaker::VERSION ); my $meta = { "abstract" => "munge your \"has\" (works with Moo, Moose and Mouse)", "author" => ["Toby Inkster (TOBYINK) "], "dynamic_config" => 1, "generated_by" => "Dist::Inkt::Profile::TOBYINK version 0.024, CPAN::Meta::Converter version 2.150010", "keywords" => [], "license" => ["perl_5"], "meta-spec" => { url => "http://search.cpan.org/perldoc?CPAN::Meta::Spec", version => 2, }, "name" => "MooseX-MungeHas", "no_index" => { directory => ["eg", "examples", "inc", "t", "xt"] }, "prereqs" => { configure => { requires => { "ExtUtils::MakeMaker" => 6.17 } }, develop => { recommends => { "Dist::Inkt" => 0 } }, runtime => { requires => { "perl" => "5.008000", "Sub::Util" => "1.40" }, suggests => { "Class::Tiny::Antlers" => 0, "Moo" => "1.002000", "Moose" => "2.0000", "Mouse" => "1.00", }, }, test => { recommends => { "Moo" => "1.002000", "Moose" => "2.0000", "Types::Standard" => 0.006 }, requires => { "Test::Fatal" => 0, "Test::More" => 0.96, "Test::Requires" => 0.06 }, suggests => { Mouse => "1.00" }, }, }, "provides" => { "MooseX::MungeHas" => { file => "lib/MooseX/MungeHas.pm", version => 0.011 }, }, "release_status" => "stable", "resources" => { bugtracker => { web => "http://rt.cpan.org/Dist/Display.html?Queue=MooseX-MungeHas", }, homepage => "https://metacpan.org/release/MooseX-MungeHas", license => ["http://dev.perl.org/licenses/"], repository => { type => "git", url => "git://github.com/tobyink/p5-moosex-mungehas.git", web => "https://github.com/tobyink/p5-moosex-mungehas", }, x_identifier => "http://purl.org/NET/cpan-uri/dist/MooseX-MungeHas/project", }, "version" => 0.011, "x_contributors" => [ "Andrew Rodland (ARODLAND) ", "Aaron Crane (ARC) ", ], }; my %dynamic_config; do { $meta->{prereqs}{runtime}{requires}{'Eval::TypeTiny'} = '0.006' unless eval { require Eval::Closure }; }; my %WriteMakefileArgs = ( ABSTRACT => $meta->{abstract}, AUTHOR => ($EUMM >= 6.5702 ? $meta->{author} : $meta->{author}[0]), DISTNAME => $meta->{name}, VERSION => $meta->{version}, EXE_FILES => [ map $_->{file}, values %{ $meta->{x_provides_scripts} || {} } ], NAME => do { my $n = $meta->{name}; $n =~ s/-/::/g; $n }, test => { TESTS => "t/*.t" }, %dynamic_config, ); $WriteMakefileArgs{LICENSE} = $meta->{license}[0] if $EUMM >= 6.3001; sub deps { my %r; for my $stage (@_) { for my $dep (keys %{$meta->{prereqs}{$stage}{requires}}) { next if $dep eq 'perl'; my $ver = $meta->{prereqs}{$stage}{requires}{$dep}; $r{$dep} = $ver if !exists($r{$dep}) || $ver >= $r{$dep}; } } \%r; } my ($build_requires, $configure_requires, $runtime_requires, $test_requires); if ($EUMM >= 6.6303) { $WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build'); $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{TEST_REQUIRES} ||= deps('test'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime'); } elsif ($EUMM >= 6.5503) { $WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build', 'test'); $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime'); } elsif ($EUMM >= 6.52) { $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime', 'build', 'test'); } else { $WriteMakefileArgs{PREREQ_PM} ||= deps('configure', 'build', 'test', 'runtime'); } { my ($minperl) = reverse sort( grep defined && /^[0-9]+(\.[0-9]+)?$/, map $meta->{prereqs}{$_}{requires}{perl}, qw( configure build runtime ) ); if (defined($minperl)) { die "Installing $meta->{name} requires Perl >= $minperl" unless $] >= $minperl; $WriteMakefileArgs{MIN_PERL_VERSION} ||= $minperl if $EUMM >= 6.48; } } sub FixMakefile { return unless -d 'inc'; my $file = shift; local *MAKEFILE; open MAKEFILE, "< $file" or die "FixMakefile: Couldn't open $file: $!; bailing out"; my $makefile = do { local $/; }; close MAKEFILE or die $!; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; open MAKEFILE, "> $file" or die "FixMakefile: Couldn't open $file: $!; bailing out"; print MAKEFILE $makefile or die $!; close MAKEFILE or die $!; } my $mm = WriteMakefile(%WriteMakefileArgs); FixMakefile($mm->{FIRST_MAKEFILE} || 'Makefile'); exit(0); README000644001750001750 1232313412643246 14135 0ustar00taitai000000000000MooseX-MungeHas-0.011NAME MooseX::MungeHas - munge your "has" (works with Moo, Moose and Mouse) SYNOPSIS package Foo::Bar; use Moose; use MooseX::MungeHas "is_ro"; has foo => (); # read-only has bar => (is => "rw"); # read-write DESCRIPTION MooseX::MungeHas alters the behaviour of the attributes of your Moo, Moose or Mouse based class. It manages to support all three because it doesn't attempt to do anything smart with metathingies; it simply installs a wrapper for `has` that munges the attribute specification hash before passing it on to the original `has` function. The following munges are always applied (simply because I can see no sensible reason why you would not want them to be). * Implement `is => "rwp"` and `is => "lazy"` in Moose and Mouse. (These already work in Moo.) * Implement `builder => 1`, `clearer => 1`, `predicate => 1`, and `trigger => 1` in Moose and Mouse. (These already work in Moo.) * Implement `builder => sub { ... }` in Moose and Mouse. (This already works in Moo.) * Allow Moo to support `coerce => 0|1` for Type::Tiny type constraints. (Moo normally expects a coderef for the coercion.) (These already work in Moose and Mouse, and has actually been added to Moo as of version 1.006000.) * Makes `has $name => sub { ... }` into a shortcut for: has $name => (is => "lazy", builder => sub { ... }); * Makes `has $name => $type_constraint` into a shortcut for: has $name => (isa => $type_constraint); (Assuming that $type_constraint is a blessed type constraint object a la Type::Tiny, MooseX::Types, etc.) * Makes `lazy => sub { ... }` into a shortcut for: lazy => 1, builder => sub { ... }, When you import this module (i.e. `use MooseX::MungeHas`) you can provide a list of additional mungers you want it to apply. These may be provided as coderefs, though for a few common, useful sets of behaviour, there are pre-defined shortcut strings. # "no_isa" is a pre-defined shortcut; # the other munger is a coderef. # use MooseX::MungeHas "no_isa", sub { # Make constructor ignore private attributes $_{init_arg} = undef if /^_/; }; Within coderefs, the name of the attribute being processed is available in the $_ variable, and the specification hash is available as %_. You may provide multiple coderefs. The following are the pre-defined shortcuts: `is_ro`, `is_rw`, `is_rwp`, `is_lazy` These mungers supply defaults for the `is` option. `always_coerce` Automatically provides `coerce => 1` if the type constraint provides coercions. (Unless you've explicitly specified `coerce => 0`.) `always_required` Automatically provides `required => 1` unless there is a default or builder. (Unless you've explicitly specified `required => 0`.) `no_isa` Switches off `isa` checks for attributes, unless they coerce. `simple_isa` Loosens type constraints if they don't coerce, and if it's likely to make them significantly faster. (Loosening `Int` to `Num` won't speed it up.) Only works if you're using Type::Tiny constraints. Mungers provided as coderefs are executed *after* predefined ones, but are otherwise executed in the order specified. Multiple Wrappers Since version 0.007, it has been possible to use MooseX::MungeHas to export multiple wrappers with different names: package Foo; use Moose; use MooseX::MungeHas { has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; Note in the example above, MooseX::MungeHas has installed two brand new wrapped `has` functions with different names, but it has left the standard `has` function unmolested. If you wanted to alter the standard function too, then you could use: package Foo; use Moose; use MooseX::MungeHas { has => [ "always_coerce" ], has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; BUGS Please report any bugs to . SEE ALSO Moo, Mouse, Moose, MooseX::AttributeShortcuts, MooseX::InlineTypes, Type::Tiny::Manual. Similar: MooseX::HasDefaults, MooseX::Attributes::Curried, MooseX::Attribute::Prototype and MooseX::AttributeDefaults. AUTHOR Toby Inkster . COPYRIGHT AND LICENCE This software is copyright (c) 2013-2014, 2017 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. DISCLAIMER OF WARRANTIES THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. SIGNATURE000644001750001750 403513412643246 14522 0ustar00taitai000000000000MooseX-MungeHas-0.011This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.81. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 99320e97df8961780157380e377d7d3ee509dff5 COPYRIGHT SHA1 7a5660b2c45bc3fcaab10ad36a79a97f92b09212 CREDITS SHA1 842cc69f74a3d2c11caf5994bac0daf9a840ccbc Changes SHA1 0201316de11793b516748517282bc17326174d06 INSTALL SHA1 529a6c89bb1ec1ab70f21730c345dcbda3871ed8 LICENSE SHA1 ded59d720fcc7bcbfd27a9e084dd506f62596ebb MANIFEST SHA1 12bc91e13a9bb044004bdb4473a67a1e785b48f4 META.json SHA1 d8f7fcce53ecce856a55f290526f217fc3357cf1 META.yml SHA1 09c2b85f1d5dd552f448fefe37a5c894cab850f0 Makefile.PL SHA1 6ab541611064e1d6e3e1dc11c04c66ee210b440c README SHA1 84df85d3af53361fcc3e9a67d4de00db41c51a0e dist.ini SHA1 413549e30c28c9f4e83797c5c6bcd2f13f19ff47 doap.ttl SHA1 402909c5eb5f1bfe84d8f59867e7524bd09261a4 examples/relax-type-constraints.pl SHA1 c07c20944b942ae235a96ac7663bc15ebdfbca0b lib/MooseX/MungeHas.pm SHA1 ab48d4d2abb7400eaecd8846e06e117b3a0ed217 t/01basic.t SHA1 52c3227deeaa89103c9f551451096251fdfd09a7 t/02moose.t SHA1 4325610493d42cf6603238ca318ddce50f879ec1 t/03moo.t SHA1 25f265828d826d842b386c11455d27d925fbe916 t/04mouse.t SHA1 cc154d13f53fe4d0f9218bd896dad5ec53e097d2 t/05multihas.t SHA1 865ed5a65fa629dce0b00a6dff176f708b5f3140 t/06multiattr.t SHA1 5dc47a506f6489f26db1d9041aa2f2e55b350b2f t/07lazy.t SHA1 10f6aec5e5e87875f5a2dcd62c25a4cba6233b36 t/08rolebuildersub.t SHA1 ea09061af21ded3bf11a03f0b0a458914c8631c2 t/09undefbare.t -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQRVJKj/4+s6z4WzNujOv4Eoaip9OQUCXCtGpgAKCRDOv4Eoaip9 OV3DAKCi7eiilyXor2Ysb0qy/19h5uC0dwCcDc3/IX0/B6B3SEUE9SluCdsoAVs= =JhAh -----END PGP SIGNATURE----- dist.ini000644001750001750 15413412643246 14660 0ustar00taitai000000000000MooseX-MungeHas-0.011; Configuration file for Dist::Inkt ; ;; class = 'Dist::Inkt::Profile::TOBYINK' ;; name = 'MooseX-MungeHas' doap.ttl000644001750001750 3720513412643246 14733 0ustar00taitai000000000000MooseX-MungeHas-0.011@prefix cpan-uri: . @prefix dc: . @prefix doap: . @prefix doap-bugs: . @prefix doap-changeset: . @prefix doap-deps: . @prefix foaf: . @prefix rdfs: . @prefix xsd: . dc:title "the same terms as the perl 5 programming language system itself". a doap:Project; dc:contributor ; doap-deps:develop-recommendation [ doap-deps:on "Dist::Inkt"^^doap-deps:CpanId ]; doap-deps:runtime-requirement [ doap-deps:on "perl 5.008000"^^doap-deps:CpanId ], [ doap-deps:on "Sub::Util 1.40"^^doap-deps:CpanId ]; doap-deps:runtime-suggestion [ doap-deps:on "Moo 1.002000"^^doap-deps:CpanId ], [ doap-deps:on "Moose 2.0000"^^doap-deps:CpanId ], [ doap-deps:on "Mouse 1.00"^^doap-deps:CpanId ], [ doap-deps:on "Class::Tiny::Antlers"^^doap-deps:CpanId; ]; doap-deps:test-recommendation [ doap-deps:on "Moose 2.0000"^^doap-deps:CpanId ], [ doap-deps:on "Moo 1.002000"^^doap-deps:CpanId ], [ doap-deps:on "Types::Standard 0.006"^^doap-deps:CpanId; ]; doap-deps:test-requirement [ doap-deps:on "Test::More 0.96"^^doap-deps:CpanId ], [ doap-deps:on "Test::Requires 0.06"^^doap-deps:CpanId; ], [ doap-deps:on "Test::Fatal"^^doap-deps:CpanId ]; doap-deps:test-suggestion [ doap-deps:on "Mouse 1.00"^^doap-deps:CpanId ]; doap:bug-database ; doap:created "2013-05-27"^^xsd:date; doap:developer ; doap:download-page ; doap:homepage ; doap:license ; doap:maintainer ; doap:name "MooseX-MungeHas"; doap:programming-language "Perl"; doap:release , , , , , , , , , , , , , , ; doap:repository [ a doap:GitRepository; doap:browse ; ]; doap:shortdesc "munge your \"has\" (works with Moo, Moose and Mouse)". a cpan-uri:DeveloperRelease, doap:Version; rdfs:label "Preview release"; dc:identifier "MooseX-MungeHas-0.000_01"^^xsd:string; dc:issued "2013-05-27"^^xsd:date; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_01"^^xsd:string. a cpan-uri:DeveloperRelease, doap:Version; dc:identifier "MooseX-MungeHas-0.000_02"^^xsd:string; dc:issued "2013-05-31"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Packaging; rdfs:label "Depend on newer version of Eval::TypeTiny."; ], [ a doap-changeset:Addition; rdfs:label "Make coerce => 0|1 work in Moo."; ], [ a doap-changeset:Removal; rdfs:label "Drop the idea of shortcutting import with a single coderef; it doesn't work out so well."; ], [ a doap-changeset:Packaging; rdfs:label "Much improved test suite."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_02"^^xsd:string. a cpan-uri:DeveloperRelease, doap:Version; dc:identifier "MooseX-MungeHas-0.000_03"^^xsd:string; dc:issued "2013-05-31"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Fix weird overloading-related bug in Perl < 5.17."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_03"^^xsd:string. a cpan-uri:DeveloperRelease, doap:Version; dc:identifier "MooseX-MungeHas-0.000_04"^^xsd:string; dc:issued "2013-05-31"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "local @_ doesn't work with goto in Perl < 5.18. (Only affects Mouse.)"; doap-changeset:thanks ; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_04"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.001"^^xsd:string; dc:issued "2013-06-12"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition, doap-changeset:Documentation; rdfs:label "examples/relax-type-constraints.pl"; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.001"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.002"^^xsd:string; dc:issued "2013-08-20"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Fix syntax error compiling the eq_1 munger."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.002"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.003"^^xsd:string; dc:issued "2013-08-28"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Use the `$_` variable for the attribute name instead of `$.`."; ], [ a doap-changeset:Change; rdfs:label "Use the `%_` hash for the attribute spec instead of `%$_`."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.003"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.004"^^xsd:string; dc:issued "2013-08-29"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Fix a stray `$.` that wasn't changed in 0.003."; doap-changeset:blame ; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.004"^^xsd:string. a doap:Version; rdfs:label "tobyink ♥ isa"; dc:identifier "MooseX-MungeHas-0.005"^^xsd:string; dc:issued "2014-02-14"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Allow Moo-style isa=>sub{...} in Moose and Mouse."; ], [ a doap-changeset:Change; rdfs:label "Remove the absolute dependency on Eval::TypeTiny; allow Eval::Closure to be used in its stead."; ], [ a doap-changeset:Change; rdfs:label "Always enable the eq_1 feature; it's never useful for it to be disabled."; ], [ a doap-changeset:Documentation; rdfs:label "Various documentation improvements."; ], [ a doap-changeset:Bugfix; rdfs:label "s/find_or_parse_type_constraint/find_or_create_isa_type_constraint/"; doap-changeset:fixes ; doap-changeset:thanks ; ], [ a doap-changeset:Packaging; rdfs:label "No longer depend on Eval::TypeTiny."; ], [ a doap-changeset:Packaging, doap-changeset:Tests; rdfs:label "No longer depend on Types::Standard for tests; skip those tests if it's not installed."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.005"^^xsd:string. a doap:Version; rdfs:label "tobyink ♥ builder"; dc:identifier "MooseX-MungeHas-0.006"^^xsd:string; dc:issued "2014-09-09"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Allow Object::Simple-style `has $name=>$coderef` in Moo, Moose, and Mouse."; ], [ a doap-changeset:Change; rdfs:label "Allow `has $name=>$type` in Moo, Moose, and Mouse."; ], [ a doap-changeset:Change; rdfs:label "Allow Moo-style `builder=>$coderef` in Moose and Mouse."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.006"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.007"^^xsd:string; dc:issued "2014-09-09"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Better detection of OO framework."; ], [ a doap-changeset:Change; rdfs:label "Allow exporting of more than one `has` function."; ], [ a doap-changeset:Change; rdfs:label "Bugfix for interaction of `is_rw` and `has $name=>$builder`."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.007"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.008"^^xsd:string; dc:issued "2017-05-27"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Make sure that has(\\@attr, %spec) works."; doap-changeset:fixes ; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.008"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.009"^^xsd:string; dc:issued "2018-07-28"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Don't use fully-qualified sub names for builders."; doap-changeset:blame ; rdfs:seeAlso ; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.009"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.010"^^xsd:string; dc:issued "2018-07-28"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Tests; rdfs:label "Make 07lazy.t actually test something useful. I can't remember why this test case even exists."; ], [ a doap-changeset:Bugfix; rdfs:label "Eliminate uninitialized warning when no `is` under Moose."; doap-changeset:blame ; rdfs:seeAlso ; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.010"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.011"^^xsd:string; dc:issued "2019-01-01"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition; rdfs:label "Add always_required feature."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.011"^^xsd:string. a foaf:Person; foaf:name "Aaron Crane"; foaf:nick "ARC"; foaf:page . a foaf:Person; foaf:name "Andrew Rodland"; foaf:nick "ARODLAND"; foaf:page . a foaf:Person; foaf:mbox ; foaf:name "Toby Inkster"; foaf:nick "TOBYINK"; foaf:page . a doap-bugs:Issue; doap-bugs:id "121895"^^xsd:string; doap-bugs:page . a doap-bugs:Issue; doap-bugs:id "92557"^^xsd:string; doap-bugs:page . foaf:name "Pierre Masci"; foaf:page . a foaf:Person; foaf:name "Luc J. Bourhis"; foaf:page . relax-type-constraints.pl000644001750001750 401113412643246 22042 0ustar00taitai000000000000MooseX-MungeHas-0.011/examplesuse strict; use warnings; use Time::HiRes qw(time); { package Person; use Moose; use Types::Standard qw(Int Str); use MooseX::MungeHas $ENV{PERL_FASTER} ? qw(is_ro no_isa) : qw(is_ro); my $Natural = Int->create_child_type( name => "NaturalNumber", constraint => sub { $_ >= 0 }, ); has name => (isa => Str, required => 1); has age => (isa => $Natural); __PACKAGE__->meta->make_immutable; } my $start = time; while () { /^(.+)\|(.+)$/ and Person->new(name => $1, age => $2); } my $finish = time; printf("Completed run in: %0.6f s.\n", $finish - $start); =pod =encoding utf-8 =head1 PURPOSE Here's a simple use case for MooseX::MungeHas. View this files's source code for the full script. We use an environment variable to toggle type constraint checks: use MooseX::MungeHas $ENV{PERL_FASTER} ? qw(is_ro no_isa) : qw(is_ro); When the code is run normally (e.g. on a development machine), the C munger is not in effect. When run on a machine with the C environment variable set to true (e.g. on the production machine), the C munger strings into action, and type constraints cease to be checked. (Because any type errors would have cropped up on the development machines, right??) =head1 OUTPUT Your machine is probably faster than mine, but a typical output with C false is: Completed run in: 0.002362 s. And with C true: Completed run in: 0.001246 s. =head1 DEPENDENCIES Example requires L and L. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut __DATA__ Alice|10 Bob|11 Carol|12 Dave|10 Eve|11 Freddie|10 Greg|11 Hattie|9 Isabel|8 Jack|10 Kevin|11 Lisa|12 Maggie|9 Nils|10 Oliver|11 Peter|10 Quentin|9 Rachel|11 Simon|12 Tessa|8 Usma|9 Veronica|11 Wendy|10 Xavier|10 Yolande|11 Zachary|9 01basic.t000644001750001750 70513412643246 15070 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas compiles. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::More; require MooseX::MungeHas; ok 1; done_testing; 02moose.t000644001750001750 551213412643246 15153 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas features work with Moose. =head1 DEPENDENCIES Test requires Moose 2.0000 and Types::Standard 0.006 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::Requires { "Moose" => "2.0000" }; use Test::Requires { "Types::Standard" => "0.006" }; use Test::More; use Types::Standard -types; my $Even = Int->create_child_type( name => "Even", constraint => sub { $_ % 2 == 0 }, )->plus_coercions(Int, '2 * $_'); { package Local::Class1; use Moose; use MooseX::MungeHas qw( is_ro simple_isa always_coerce ); has attr1 => $Even; has attr2 => (isa => $Even, coerce => 0); # this should be simplified to Int has attr3 => (isa => $Even, is => "rwp"); has attr4 => (isa => $Even, is => "lazy", default => sub { 42 }); has attr5 => sub { 999 }; } ok( Local::Class1->meta->get_attribute("attr$_")->should_coerce, qq[Local::Class1->meta->get_attribute("attr$_")->should_coerce], ) for 1, 3, 4; ok( !Local::Class1->meta->get_attribute("attr2")->should_coerce, q[not Local::Class1->meta->get_attribute("attr2")->should_coerce], ); ok( Local::Class1->meta->get_attribute("attr$_")->type_constraint == $Even, qq[Local::Class1->meta->get_attribute("attr$_")->type_constraint == \$Even], ) || diag(Local::Class1->meta->get_attribute("attr1")->type_constraint) for 1, 3, 4; ok( Local::Class1->meta->get_attribute("attr2")->type_constraint == Int, q[Local::Class1->meta->get_attribute("attr2")->type_constraint == Int], ) or diag(Local::Class1->meta->get_attribute("attr2")->type_constraint); can_ok("Local::Class1", "_set_attr3"); my $o = Local::Class1->new; ok( !$o->meta->get_meta_instance->is_slot_initialized($o, "attr4"), '$o->attr4 is not initialized', ); is( $o->attr4, 42, 'default worked', ); ok( $o->meta->get_meta_instance->is_slot_initialized($o, "attr4"), '$o->attr4 is now initialized', ); ok( !$o->meta->get_meta_instance->is_slot_initialized($o, "attr5"), '$o->attr5 is not initialized', ); is( $o->attr5, 999, 'default worked', ); ok( $o->meta->get_meta_instance->is_slot_initialized($o, "attr5"), '$o->attr5 is now initialized', ); { package Local::Class2; use Moose; use MooseX::MungeHas qw( is_ro always_required ); has attr1 => $Even; has attr2 => (isa => $Even, required => 0); has attr3 => (isa => $Even, default => sub { 42 }); } use Test::Fatal; my $e1 = exception { Local::Class2->new(attr1 => 2) }; is($e1, undef, "attr2 and attr3 shouldn't be required"); my $e2 = exception { Local::Class2->new(attr2 => 2) }; like($e2, qr/required/i, "attr1 should be required"); done_testing; 03moo.t000644001750001750 427113412643246 14625 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas features work with Moo. =head1 DEPENDENCIES Test requires Moo 1.000000 and Types::Standard 0.006 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::Requires { "Moo" => "1.000000" }; use Test::Requires { "Types::Standard" => "0.006" }; use Test::More; use Test::Fatal; use Types::Standard -types; my $Even = Int->create_child_type( name => "Even", constraint => sub { $_ % 2 == 0 }, )->plus_coercions(Int, '2 * $_'); { package Local::Class1; use Moo; use MooseX::MungeHas qw( is_ro simple_isa always_coerce ); has attr1 => $Even; has attr2 => (isa => $Even, coerce => 0); # this should be simplified to Int has attr3 => (isa => $Even, is => "rwp"); has attr4 => (isa => $Even, is => "lazy", default => sub { 42 }); has attr5 => sub { 999 }; } is( Local::Class1->new("attr$_" => 333)->${\"attr$_"}, 666, qq[Local::Class1 attribute attr$_ coerces], ) for 1, 3, 4; is( Local::Class1->new("attr2" => 333)->attr2, 333, q[attr2 accepts an odd Int because its type check has been simplified], ); can_ok("Local::Class1", "_set_attr3"); my $o = Local::Class1->new; ok( !exists $o->{attr4}, '$o->attr4 is not initialized', ); is( $o->attr4, 42, 'default worked', ); ok( exists $o->{attr4}, '$o->attr4 is now initialized', ); ok( !exists $o->{attr5}, '$o->attr5 is not initialized', ); is( $o->attr5, 999, 'default worked', ); ok( exists $o->{attr5}, '$o->attr5 is now initialized', ); { package Local::Class2; use Moo; use MooseX::MungeHas qw( is_ro always_required ); has attr1 => $Even; has attr2 => (isa => $Even, required => 0); has attr3 => (isa => $Even, default => sub { 42 }); } use Test::Fatal; my $e1 = exception { Local::Class2->new(attr1 => 2) }; is($e1, undef, "attr2 and attr3 shouldn't be required"); my $e2 = exception { Local::Class2->new(attr2 => 2) }; like($e2, qr/required/i, "attr1 should be required"); done_testing; 04mouse.t000644001750001750 523313412643246 15163 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas features work with Mouse. =head1 DEPENDENCIES Test requires Mouse 1.00 and Types::Standard 0.006 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::Requires { "Mouse" => "1.00" }; use Test::Requires { "Types::Standard" => "0.006" }; use Test::More; use Types::Standard -types; my $Even = Int->create_child_type( name => "Even", constraint => sub { $_ % 2 == 0 }, )->plus_coercions(Int, '2 * $_'); { package Local::Class1; use Mouse; use MooseX::MungeHas qw( is_ro simple_isa always_coerce ); has attr1 => $Even; has attr2 => (isa => $Even, coerce => 0); # this should be simplified to Int has attr3 => (isa => $Even, is => "rwp"); has attr4 => (isa => $Even, is => "lazy", default => sub { 42 }); has attr5 => sub { 999 }; } ok( Local::Class1->meta->get_attribute("attr$_")->should_coerce, qq[Local::Class1->meta->get_attribute("attr$_")->should_coerce], ) for 1, 3, 4; ok( !Local::Class1->meta->get_attribute("attr2")->should_coerce, q[not Local::Class1->meta->get_attribute("attr2")->should_coerce], ); ok( Local::Class1->meta->get_attribute("attr$_")->type_constraint == $Even, qq[Local::Class1->meta->get_attribute("attr$_")->type_constraint == \$Even], ) || diag(Local::Class1->meta->get_attribute("attr1")->type_constraint) for 1, 3, 4; ok( Local::Class1->meta->get_attribute("attr2")->type_constraint == Int, q[Local::Class1->meta->get_attribute("attr2")->type_constraint == Int], ) or diag(Local::Class1->meta->get_attribute("attr2")->type_constraint); can_ok("Local::Class1", "_set_attr3"); my $o = Local::Class1->new; ok( !exists $o->{attr4}, '$o->attr4 is not initialized', ); is( $o->attr4, 42, 'default worked', ); ok( exists $o->{attr4}, '$o->attr4 is now initialized', ); ok( !exists $o->{attr5}, '$o->attr5 is not initialized', ); is( $o->attr5, 999, 'default worked', ); ok( exists $o->{attr5}, '$o->attr5 is now initialized', ); { package Local::Class2; use Mouse; use MooseX::MungeHas qw( is_ro always_required ); has attr1 => $Even; has attr2 => (isa => $Even, required => 0); has attr3 => (isa => $Even, default => sub { 42 }); } use Test::Fatal; my $e1 = exception { Local::Class2->new(attr1 => 2) }; is($e1, undef, "attr2 and attr3 shouldn't be required"); my $e2 = exception { Local::Class2->new(attr2 => 2) }; like($e2, qr/required/i, "attr1 should be required"); done_testing; 05multihas.t000644001750001750 222313412643246 15656 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test that it is possible to export multiple C mungers. =head1 DEPENDENCIES Test requires Moose 2.0000 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2014 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::Requires { "Moose" => "2.0000" }; use Test::More; { package Local::Class1; use Moose; use MooseX::MungeHas { has_ro => ['is_ro'], has_rw => ['is_rw'], }; has_ro "attr1"; has_ro "attr2", sub { 666 }; has_rw "attr3"; has_rw "attr4", sub { 999 }; } is( Local::Class1->meta->get_attribute("attr$_")->{is}, "ro", qq[Local::Class1->meta->get_attribute("attr$_")->{is} eq "ro"], ) for 1, 2; is( Local::Class1->meta->get_attribute("attr$_")->{is}, "rw", qq[Local::Class1->meta->get_attribute("attr$_")->{is} eq "rw"], ) for 3, 4; is( Local::Class1->new->attr2, 666, '$o->attr2 builder', ); is( Local::Class1->new->attr4, 999, '$o->attr4 builder', ); done_testing; 06multiattr.t000644001750001750 132213412643246 16055 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test that C<< has \@attrs => %spec >> works. =head1 DEPENDENCIES Test requires Moose 2.0000 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2017 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::Requires { "Moose" => "2.0000" }; use Test::More; { package Local::Class1; use Moose; use MooseX::MungeHas qw(is_ro); has [qw/ one two /] => sub { "xyz" }; } my $obj = Local::Class1::->new; is($obj->one, 'xyz'); is($obj->two, 'xyz'); done_testing; 07lazy.t000644001750001750 111013412643246 15003 0ustar00taitai000000000000MooseX-MungeHas-0.011/tuse Test::More tests => 3; use strict; use warnings; { package XXX; use Test::Requires "Moo"; } { package YYY; use Test::Requires "Moose"; } { package ZZZ; use Test::Requires "Mouse"; } subtest $_, \&test_lazy, $_ for qw/ Moo Moose Mouse /; sub test_lazy { my $framework = shift; my $class = eval qq! package Foo::$framework; use $framework; use MooseX::MungeHas; has bar => ( is => 'ro', lazy => sub { 'got it' }, ); __PACKAGE__; !; ok $class, "class building worked for $class"; is $class->new->bar => 'got it', 'lazy attribute works'; } 08rolebuildersub.t000644001750001750 164613412643246 17065 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test C<< has attr => (builder => sub {}) >> works in a role. =head1 DEPENDENCIES Test requires Moo or is skipped. =head1 AUTHOR Aaron Crane Earc@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2017 by Aaron Crane. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::Requires 'Moo'; use Test::More; { package Local::Role1; use Moo::Role; use MooseX::MungeHas; has attr => (is => 'lazy', builder => sub { 'from role' }); } { package Local::Class1; use Moo; with 'Local::Role1'; sub _build_attr { 'from class' } } { package Local::Class2; use Moo; with 'Local::Role1'; around _build_attr => sub { 'from class' }; } is(Local::Class1->new->attr, 'from class'); is(Local::Class2->new->attr, 'from class'); done_testing; 09undefbare.t000644001750001750 163413412643246 15774 0ustar00taitai000000000000MooseX-MungeHas-0.011/t=pod =encoding utf-8 =head1 PURPOSE Test C<< has '+attr' => (default => ...) >> under Moose yields no warnings. =head1 DEPENDENCIES Test requires Moose or is skipped. =head1 AUTHOR Aaron Crane Earc@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2017 by Aaron Crane. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut use strict; use warnings; use Test::Requires 'Moose'; use Test::More; my @warnings; local $^W = 1; local $SIG{__WARN__} = sub { push @warnings, shift }; { package Local::Base; use Moose; use MooseX::MungeHas; has attr => (is => 'ro', required => 1); } { package Local::Derived; use Moose; use MooseX::MungeHas; extends 'Local::Base'; has '+attr' => (default => 17); } is_deeply(\@warnings, [], 'no warnings issued') or diag explain(\@warnings); done_testing; MungeHas.pm000644001750001750 3204213412643246 17302 0ustar00taitai000000000000MooseX-MungeHas-0.011/lib/MooseXpackage MooseX::MungeHas; use 5.008; use strict; use warnings; BEGIN { $MooseX::MungeHas::AUTHORITY = 'cpan:TOBYINK'; $MooseX::MungeHas::VERSION = '0.011'; }; use Carp qw(croak); use Scalar::Util qw(blessed); BEGIN { for my $backend (qw/ Eval::TypeTiny Eval::Closure /) { last if eval( "require $backend; *eval_closure = \\&$backend\::eval_closure;" ); } exists(&eval_closure) or croak "Could not load Eval::TypeTiny"; }; sub import { no strict qw(refs); my $class = shift; my $caller = caller; my $orig = \&{"$caller\::has"} or croak "$caller does not have a 'has' function to munge"; my %export = (@_ == 1 and ref($_[0]) eq "HASH") ? %{ $_[0] } : ( has => [@_] ); for my $f (sort keys %export) { no warnings qw(redefine prototype); *{"$caller\::$f"} = $class->_make_has( $caller, $class->_make_munger($caller, @{$export{$f}}), $orig, ); } } { sub __detect_oo { my $package = $_[0]; if ($INC{'Moo.pm'}) { return "Moo" if $Moo::MAKERS{$package}; return "Moo" if $Moo::Role::INFO{$package}; } if ($INC{'Moose.pm'}) { require Moose::Util; return "Moose" if Moose::Util::find_meta($package); } if ($INC{'Mouse.pm'}) { require Mouse::Util; return "Mouse" if Mouse::Util::find_meta($package); } my $meta; eval { $meta = $package->meta } or return "?"; return "Moo" if ref($meta) eq "Moo::HandleMoose::FakeMetaClass"; return "Mouse" if $meta->isa("Mouse::Meta::Module"); return "Moose" if $meta->isa("Moose::Meta::Class"); return "Moose" if $meta->isa("Moose::Meta::Role"); return "?"; } my %_cache; sub _detect_oo { $_cache{$_[0]} ||= __detect_oo(@_) }; } sub _make_munger { my $class = shift; return $class->_compile_munger_code(@_); } sub _compile_munger_code { my $class = shift; my ($caller, @features) = @_; my %features = map +($_ => 1), grep !ref, @features; my @subs = grep ref, @features; my @code = "sub {"; if (_detect_oo($caller) =~ /^Mo[ou]se$/) { push @code, ' if (exists($_{isa}) && !ref($_{isa})) {'; push @code, ' $_{isa} = '._detect_oo($caller).'::Util::TypeConstraints::find_or_create_isa_type_constraint($_{isa});'; push @code, ' }'; } for my $is (qw/ro rw rwp lazy bare/) { if (delete $features{"is_$is"}) { push @code, ' $_{is} ||= "'.$is.'";'; } } push @code, ' if (exists($_{_is})) {'; push @code, ' my $_is = delete($_{_is});'; push @code, ' $_{is} ||= $_is;'; push @code, ' }'; push @code, 'if ( ref $_{lazy} eq q(CODE) ) {'; push @code, ' $_{builder} ||= $_{lazy};'; push @code, '}'; push @code, ' if (ref($_{builder}) eq q(CODE)) {'; push @code, ' no strict qw(refs);'; push @code, ' require Sub::Util;'; push @code, ' my $short_name = "_build_$_";'; push @code, ' my $name = "$_{__CALLER__}::$short_name";'; push @code, ' *$name = Sub::Util::set_subname($name, $_{builder});'; push @code, ' $_{builder} = $short_name;'; push @code, ' }'; unless (_detect_oo($caller) eq "Moo") { push @code, ' my $is = $_{is} || "";'; push @code, ' if ($is eq q(lazy)) {'; push @code, ' $_{is} = "ro";'; push @code, ' $_{lazy} = 1 unless exists($_{lazy});'; push @code, ' $_{builder} = "_build_$_" if $_{lazy} && !exists($_{builder}) && !exists($_{default});'; push @code, ' }'; push @code, ' if ($is eq q(rwp)) {'; push @code, ' $_{is} = "ro";'; push @code, ' $_{writer} = "_set_$_" unless exists($_{writer});'; push @code, ' }'; push @code, ' if (ref($_{isa}) eq q(CODE)) {'; push @code, ' require Type::Tiny;'; push @code, ' my $code = $_{isa};'; push @code, ' my $safe = sub { !!eval { $code->($_); 1 } };'; push @code, ' $_{isa} = "Type::Tiny"->new(constraint => $safe);'; push @code, ' }'; } delete $features{"eq_1"}; push @code, ' my ($pfx, $name) = ($_ =~ /^(_*)(.+)$/);'; push @code, ' $_{builder} = "_build_$_" if exists($_{builder}) && $_{builder} eq q(1);'; push @code, ' $_{clearer} = "${pfx}clear_${name}" if exists($_{clearer}) && $_{clearer} eq q(1);'; push @code, ' $_{predicate} = "${pfx}has_${name}" if exists($_{predicate}) && $_{predicate} eq q(1);'; push @code, ' if (exists($_{trigger}) && $_{trigger} eq q(1)) {'; push @code, ' my $method = "_trigger_$_";'; push @code, ' $_{trigger} = sub { shift->$method(@_) };'; push @code, ' }'; if (delete $features{"always_coerce"}) { push @code, ' if (exists($_{isa}) and !exists($_{coerce}) and Scalar::Util::blessed($_{isa}) and $_{isa}->can("has_coercion") and $_{isa}->has_coercion) {'; push @code, ' $_{coerce} = 1;'; push @code, ' }'; } if (delete $features{"always_required"}) { push @code, ' if (!exists($_{required}) and !exists($_{default}) and !exists($_{builder})) {'; push @code, ' $_{required} = 1;'; push @code, ' }'; } if (_detect_oo($caller) eq "Moo") { push @code, ' if (defined($_{coerce}) and !ref($_{coerce}) and $_{coerce} eq "1") {'; push @code, ' Scalar::Util::blessed($_{isa})'; push @code, ' and $_{isa}->isa("Type::Tiny")'; push @code, ' and ($_{coerce} = $_{isa}->coercion);'; push @code, ' }'; push @code, ' elsif (exists($_{coerce}) and not $_{coerce}) {'; push @code, ' delete($_{coerce});'; push @code, ' }'; } if (delete $features{"no_isa"}) { push @code, ' delete($_{isa}) if !exists($_{coerce});'; } if (delete $features{"simple_isa"}) { push @code, ' $_{isa} = "'.$class.'"->_simplify_isa($_{isa}) if Scalar::Util::blessed($_{isa}) && !$_{coerce};'; } push @code, sprintf(' $subs[%d]->(@_);', $_) for 0..$#subs; #push @code, ' ::diag(::explain($_, \%_));'; push @code, ' delete($_{__CALLER__});'; push @code, "}"; croak sprintf("Did not understand mungers: %s", join(q[, ], sort keys %features)) if keys %features; return eval_closure( source => \@code, environment => { '@subs' => \@subs }, ); } sub _simplify_isa { my $class = shift; my ($t) = @_; until ($t->can_be_inlined) { if ($t->has_parent) { $t = $t->parent; next; } if ($t->isa("Type::Tiny::Intersection")) { require Type::Tiny::Intersection; my (@can_be_inlined) = grep $_->can_be_inlined, @$t; $t = "Type::Tiny::Intersection"->new(type_constraints => \@can_be_inlined); next; } require Type::Tiny; return "Type::Tiny"->new; } return $t; } sub _make_has { my $class = shift; my ($caller, $coderef, $orig) = @_; return $class->_make_has_mouse(@_) if _detect_oo($caller) eq "Mouse"; return sub { my ($attr, %spec) = ( (@_ == 2 and ref($_[1]) eq "CODE") ? ($_[0], _is => "ro", lazy => 1, builder => $_[1]) : (@_ == 2 and ref($_[1]) eq "HASH") ? ($_[0], %{$_[1]}) : (@_ == 2 and blessed($_[1]) and $_[1]->can('check')) ? ($_[0], _is => "ro", isa => $_[1]) : @_ ); $spec{"__CALLER__"} = $caller; if (ref($attr) eq q(ARRAY)) { my @attrs = @$attr; for my $attr (@attrs) { local %_ = %spec; local $_ = $attr; $coderef->($attr, %_); $orig->($attr, %_); } } else { local %_ = %spec; local $_ = $attr; $coderef->($attr, %_); return $orig->($attr, %_); } }; } sub _make_has_mouse { my $class = shift; my ($caller, $coderef, $orig) = @_; return sub { my ($attr, %spec) = ( (@_ == 2 and ref($_[1]) eq "CODE") ? ($_[0], _is => "ro", lazy => 1, builder => $_[1]) : (@_ == 2 and ref($_[1]) eq "HASH") ? ($_[0], %{$_[1]}) : (@_ == 2 and blessed($_[1]) and $_[1]->can('check')) ? ($_[0], _is => "ro", isa => $_[1]) : @_ ); $spec{"__CALLER__"} = $caller; if (ref($attr) eq q(ARRAY)) { croak "MooseX::MungeHas does not support has \\\@array for Mouse"; } else { local %_ = %spec; local $_ = $attr; $coderef->($attr, %_); @_ = ($attr, %_); goto $orig; } }; } 1; __END__ =pod =encoding utf-8 =for stopwords metathingies munges mungers =begin private =item eval_closure =end private =head1 NAME MooseX::MungeHas - munge your "has" (works with Moo, Moose and Mouse) =head1 SYNOPSIS package Foo::Bar; use Moose; use MooseX::MungeHas "is_ro"; has foo => (); # read-only has bar => (is => "rw"); # read-write =head1 DESCRIPTION MooseX::MungeHas alters the behaviour of the attributes of your L, L or L based class. It manages to support all three because it doesn't attempt to do anything smart with metathingies; it simply installs a wrapper for C<< has >> that munges the attribute specification hash before passing it on to the original C<< has >> function. The following munges are always applied (simply because I can see no sensible reason why you would not want them to be). =over =item * Implement C<< is => "rwp" >> and C<< is => "lazy" >> in L and L. (These already work in L.) =item * Implement C<< builder => 1 >>, C<< clearer => 1 >>, C<< predicate => 1 >>, and C<< trigger => 1 >> in L and L. (These already work in L.) =item * Implement C<< builder => sub { ... } >> in L and L. (This already works in L.) =item * Allow L to support C<< coerce => 0|1 >> for L type constraints. (Moo normally expects a coderef for the coercion.) (These already work in L and L, and has actually been added to L as of version 1.006000.) =item * Makes C<< has $name => sub { ... } >> into a shortcut for: has $name => (is => "lazy", builder => sub { ... }); =item * Makes C<< has $name => $type_constraint >> into a shortcut for: has $name => (isa => $type_constraint); (Assuming that C<< $type_constraint >> is a blessed type constraint object a la L, L, etc.) =item * Makes C<< lazy => sub { ... } >> into a shortcut for: lazy => 1, builder => sub { ... }, =back When you import this module (i.e. C<< use MooseX::MungeHas >>) you can provide a list of additional mungers you want it to apply. These may be provided as coderefs, though for a few common, useful sets of behaviour, there are pre-defined shortcut strings. # "no_isa" is a pre-defined shortcut; # the other munger is a coderef. # use MooseX::MungeHas "no_isa", sub { # Make constructor ignore private attributes $_{init_arg} = undef if /^_/; }; Within coderefs, the name of the attribute being processed is available in the C<< $_ >> variable, and the specification hash is available as C<< %_ >>. You may provide multiple coderefs. The following are the pre-defined shortcuts: =over =item C<< is_ro >>, C<< is_rw >>, C<< is_rwp >>, C<< is_lazy >> These mungers supply defaults for the C<< is >> option. =item C<< always_coerce >> Automatically provides C<< coerce => 1 >> if the type constraint provides coercions. (Unless you've explicitly specified C<< coerce => 0 >>.) =item C<< always_required >> Automatically provides C<< required => 1 >> unless there is a default or builder. (Unless you've explicitly specified C<< required => 0 >>.) =item C<< no_isa >> Switches off C<< isa >> checks for attributes, unless they coerce. =item C<< simple_isa >> Loosens type constraints if they don't coerce, and if it's likely to make them significantly faster. (Loosening C to C won't speed it up.) Only works if you're using L constraints. =back Mungers provided as coderefs are executed I predefined ones, but are otherwise executed in the order specified. =head2 Multiple Wrappers Since version 0.007, it has been possible to use MooseX::MungeHas to export multiple wrappers with different names: package Foo; use Moose; use MooseX::MungeHas { has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; Note in the example above, MooseX::MungeHas has installed two brand new wrapped C functions with different names, but it has left the standard C function unmolested. If you wanted to alter the standard function too, then you could use: package Foo; use Moose; use MooseX::MungeHas { has => [ "always_coerce" ], has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; =head1 BUGS Please report any bugs to L. =head1 SEE ALSO L, L, L, L, L, L. Similar: L, L, L and L. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013-2014, 2017 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =head1 DISCLAIMER OF WARRANTIES THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.