Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package My::Role;
- use strict;
- use warnings;
- use Moose::Role;
- use MooseX::ClassAttribute;
- class_has table => (
- is => 'ro'
- isa => 'Str',
- lazy => 1,
- );
- has id => (
- is => 'ro',
- isa => 'Int',
- predicate => 'has_id',
- writer => '_id',
- required => 0,
- );
- has other => (
- is => 'rw',
- isa => 'Int',
- );
- ...
- 1;
- package Some::Module;
- with 'My::Role' => {
- -excludes => [qw( id table )]
- };
- has module_id => (
- is => 'ro',
- isa => 'Int',
- );
- ...
- 1;
- my $some_module = Some::Module->new({ other => 3 });
- $some_module->id; # I'd expect this to die but returns undef.
- $some_module->table; # this dies as I'd expect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement