Mojo::Bass - Mojo::Base + lexical "has"
version 0.3.0
package Cat { use Mojo::Bass -base; has name => 'Nyan'; has ['age', 'weight'] => 4; } package Tiger { use Mojo::Bass 'Cat'; has friend => sub { Cat->new }; has stripes => 42; } package main; use Mojo::Bass -strict; my $mew = Cat->new(name => 'Longcat'); say $mew->age; say $mew->age(3)->weight(5)->age; my $rawr = Tiger->new(stripes => 38, weight => 250); say $rawr->tap(sub { $_->friend->name('Tacgnol') })->weight;
Mojo::Bass works like Mojo::Base but has is imported as lexical subroutine.
has
Mojo::Bass requires perl 5.18 or newer
Because a lexical sub does not behave like a package import, some code may need to be enclosed in blocks to avoid warnings like
"state" subroutine &has masks earlier declaration in same scope at...
Mojo::Base.
Adriano Ferreira <ferreira@cpan.org>
This software is Copyright (c) 2017 by Adriano Ferreira.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Mojo::Bass, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::Bass
CPAN shell
perl -MCPAN -e shell install Mojo::Bass
For more information on module installation, please visit the detailed CPAN module installation guide.