Last active
December 18, 2017 10:13
-
-
Save andrewsolomon/30b5d77bd421bd598f7f2faee1f716b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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