Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nichtich/class-accessor-coerce
Extends class accessors with coercing
https://github.com/nichtich/class-accessor-coerce
Last synced: 5 days ago
JSON representation
Extends class accessors with coercing
- Host: GitHub
- URL: https://github.com/nichtich/class-accessor-coerce
- Owner: nichtich
- Created: 2013-03-20T11:47:50.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-03-25T06:34:54.000Z (over 11 years ago)
- Last Synced: 2024-10-30T16:24:59.965Z (about 2 months ago)
- Language: Perl
- Size: 121 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This Perl module provides functions to extend Moo accessors to support
multiple arguments. In short, it exports the following functions:sub expect_arrayref {
around @_ => sub {
my ($orig, $self, @rest) = @_;
$self->$orig( @rest ? \@rest : () );
}
}sub expect_hashref {
around @_ => sub {
my ($orig, $self, @rest) = @_;
$self->$orig( @rest ? { @rest } : () );
}
}sub undef_clears {
foreach my $name (@_) {
around $name => sub {
my ($orig, $self, @rest) = @_;
if (@rest == 1 and $rest[0] == undef) {
return delete $self->{$name};
} else {}
$self->$orig( @rest );
}
}
}
}As long as the module has not been published at CPAN, one can install it with
cpanminus >= 1.6 as following:cpanm git://github.com/nichtich/Class-Accessor-Coerce.git
Or just download the repository (e.g. by cloning) and call
make install