MooseX::Has::Sugar::Saccharin - Experimental sweetness
version 1.000001
This is a highly experimental sugaring module. No Guarantees of stability.
use MooseX::Types::Moose qw( :all ); has name => rw Str, default { 1 }; has suffix => required rw Str; has 'suffix', required rw Str;
Your choice.
:default
exports:
"ro", "rw", "required", "lazy", "lazy_build", "coerce", "weak_ref", "auto_deref", "bare", "default", "init_arg", "predicate", "clearer", "builder", "trigger"
bare
$Type
bare Str
equivalent to this
is => 'bare', isa => Str
ro
ro Str
is => 'ro', isa => Str,
rw
rw Str
is => 'rw', isa => Str
required
required @rest
this
required rw Str
is equivalent to this
required => 1, is => 'rw', isa => Str,
rw Str, required
is => 'rw', isa => Str , required => 1
lazy
lazy @rest
like ( lazy => 1 , @rest )
( lazy => 1 , @rest )
lazy_build
lazy_build @rest
like ( lazy_build => 1, @rest )
( lazy_build => 1, @rest )
weak_ref
weak_ref @rest
like ( weak_ref => 1, @rest )
( weak_ref => 1, @rest )
coerce
coerce @rest
like ( coerce => 1, @rest )
( coerce => 1, @rest )
Conflicts with MooseX::Types's coerce method
MooseX::Types's
auto_deref
auto_deref @rest
like ( auto_deref => 1, @rest )
( auto_deref => 1, @rest )
builder
builder $buildername
required rw Str, builder '_build_foo'
is like
builder => '_build_foo'
predicate
predicate $predicatename
see "builder"
clearer
clearer $clearername
init_arg
init_arg $argname
default
default { $code }
Examples:
default { 1 } default { { } } default { [ ] } default { $_->otherfield }
$_ is localized as the same value as $_[0] for convenience ( usually $self )
trigger
trigger { $code }
Works exactly like default.
This module is not intended to be used in conjunction with ::Sugar or ::Sugar::Minimal
We export many of the same symbols and its just not very sensible.
due to exporting the "coerce" symbol, using us in the same scope as a call to
use MooseX::Types ....
or use Moose::Util::TypeConstraints
will result in a symbol collision.
We recommend using and creating proper type libraries instead, ( which will absolve you entirely of the need to use MooseX::Types and MooseX::Has::Sugar(::*)? in the same scope )
the keyword 'default' becomes part of Perl in both these cases:
use 5.010; use feature qw( :switch );
As such, we can't have that keyword in that scenario.
Kent Fredric <kentnl at cpan.org>
This software is copyright (c) 2014 by Kent Fredric.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::Has::Sugar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Has::Sugar
CPAN shell
perl -MCPAN -e shell install MooseX::Has::Sugar
For more information on module installation, please visit the detailed CPAN module installation guide.