Skip to content

Instantly share code, notes, and snippets.

@semifor
Created April 23, 2016 22:14
Show Gist options
  • Select an option

  • Save semifor/2e2ee2b9e78aa932fbec7d4923996f32 to your computer and use it in GitHub Desktop.

Select an option

Save semifor/2e2ee2b9e78aa932fbec7d4923996f32 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.14.1;
use warnings;
package API {
use Moose::Role;
requires qw/store/;
}
package IntervalUsers {
use Moose::Role;
requires qw/chart_type interval_users/;
sub store {}
}
package Age {
use Moose::Role;
requires qw/age_from_user/;
# If I use an attribute, it fails the requires check. If I use a method, it succeeds.
# The documentation says:
# > Note that attribute accessors also count as methods for the purposes of
# > satisfying the requirements of a role.
sub interval_users {}
#has interval_users => ( is => 'ro' );
with qw/IntervalUsers/;
}
package AccountAges {
use Moose;
with qw/Age API/;
sub chart_type () { 'age' }
sub age_from_user {}
}
my $component = AccountAges->new;
say $component->store;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment