NAME

Mojo::Bass - Mojo::Base + lexical "has"

VERSION

version 0.3.0

SYNOPSIS

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;

DESCRIPTION

Mojo::Bass works like Mojo::Base but has is imported as lexical subroutine.

CAVEATS

  • 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...

SEE ALSO

Mojo::Base.

AUTHOR

Adriano Ferreira <ferreira@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2017 by Adriano Ferreira.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)