Udapi::Core::Common - shorten the "use
" part of your Perl codes
Write just
use Udapi::Core::Common; has_ro foo => (default=>42); has_rw bar => (default=>43, isa=>Int); # now you can use $self->set_bar(44);
Instead of
use utf8; use strict; use warnings; use feature 'say'; use open qw(:encoding(UTF-8) :std); # STD(IN|OUT|ERR) in utf8 use Moo; use Carp qw(cluck confess); use List::Util qw(first min max all any none); use Scalar::Util qw(weaken); use Data::Printer; use MooX::TypeTiny; use Types::Standard qw(Int Bool); has foo => (is=>'ro', default=>42); has bar => (is=>'ro', default=>43, writer=>'set_bar', isa=>Int);
This module saves boilerplate lines from Moo based classes. Unlike Moose, Moo has no MooseX::SemiAffordanceAccessor, which would allow for having setters with "set_" prefix (and getters without any prefix). So we include pseudokeywords has_ro
and has_rw
, which also automatically include the respective "is" type.
Martin Popel <popel@ufal.mff.cuni.cz>
Copyright © 2016 by Institute of Formal and Applied Linguistics, Charles University in Prague
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.