8 use Test::More tests => 7;
15 package My::Meta::Attribute::DefaultReadOnly;
18 extends 'Mouse::Meta::Attribute';
22 my ($self, $name, %options) = @_;
24 unless exists $options{is};
25 $next->($self, $name, %options);
30 package My::Attribute::Trait;
33 has 'alias_to' => (is => 'ro', isa => 'Str');
35 after 'install_accessors' => sub {
37 $self->associated_class->add_method(
39 $self->get_read_method_ref
49 metaclass => 'My::Meta::Attribute::DefaultReadOnly',
50 traits => [qw/My::Attribute::Trait/],
56 my $c = My::Class->new(bar => 100);
57 isa_ok($c, 'My::Class');
59 is($c->bar, 100, '... got the right value for bar');
62 is($c->baz, 100, '... got the right value for baz');
64 isa_ok($c->meta->get_attribute('bar'), 'My::Meta::Attribute::DefaultReadOnly');
65 does_ok($c->meta->get_attribute('bar'), 'My::Attribute::Trait');
66 is($c->meta->get_attribute('bar')->_is_metadata, 'ro', '... got the right metaclass customization');