Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Last active December 18, 2017 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsolomon/30b5d77bd421bd598f7f2faee1f716b3 to your computer and use it in GitHub Desktop.
Save andrewsolomon/30b5d77bd421bd598f7f2faee1f716b3 to your computer and use it in GitHub Desktop.
{
package Brand;
use Moo::Role;
has name => (
is => 'rw',
lazy => 1,
default => sub { die "name is required" }
);
sub description { "This is a nice ". shift->name }
}
{
package Car;
use Moo;
}
my $car = Car->new;
Moo::Role->apply_roles_to_object($car, 'Brand');
# $car->name("Peugeot"); # assign a name to avert termination!
say $car->description;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment