Constructor::SugarLibrary - build a library of generic constructor syntax sugar
version 0.213360
Declare syntax sugar in a library that will export it.
package My::SugarLib; use Constructor::SugarLibrary; sweeten "My::Moo::Object"; sweeten "My::Moose::Thing";
This is how you'd normally construct and check objects:
package My::NormalCode; use My::Moo::Object; use My::Moose::Thing; my $obj = My::Moo::Object->new( plus => "some", more => "data" ); die if !$obj->isa( "My::Moo::Object" ); my $obj2 = My::Moose::Thing->new( with => "other", meta => "data" ); die if !$obj->isa( "My::Moose::Thing" );
Using the sugar library the same can be done much more concisely:
package My::SugaredCode; use My::SugarLib; my $obj = object plus => "some", more => "data"; die if $obj->isa( Object ); my $obj2 = thing with => "other", meta => "data"; die if $obj->isa( Thing );
Christian Walde <walde.christian@gmail.com>
Christian Walde has dedicated the work to the Commons by waiving all of his or her rights to the work worldwide under copyright law and all related or neighboring legal rights he or she had in the work, to the extent allowable by law.
Works under CC0 do not require attribution. When citing the work, you should not imply endorsement by the author.
To install Throwable::SugarFactory, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Throwable::SugarFactory
CPAN shell
perl -MCPAN -e shell install Throwable::SugarFactory
For more information on module installation, please visit the detailed CPAN module installation guide.