Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Last active December 18, 2017 10:14
Show Gist options
  • Save andrewsolomon/b0aacbd7f7916ec0ce5dd1028479edb8 to your computer and use it in GitHub Desktop.
Save andrewsolomon/b0aacbd7f7916ec0ce5dd1028479edb8 to your computer and use it in GitHub Desktop.
{
package Brand;
use Moo::Role;
has name => ( is => 'rw', required => 1 ); # made rw
sub description { "This is a nice ". shift->name }
}
{
package Car;
use Moo;
# with 'Brand'; # not at compile time
}
my $car = Car->new;
# TODO an investigation which determines that it really is a branded car
Moo::Role->apply_roles_to_object($car, 'Brand');
# $car->name("Peugeot");
say $car->description;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment