6 use Test::More tests => 7;
13 package My::Meta::Attribute::DefaultReadOnly;
16 extends 'Mouse::Meta::Attribute';
20 my ($self, $name, %options) = @_;
22 unless exists $options{is};
23 $next->($self, $name, %options);
28 package My::Attribute::Trait;
31 has 'alias_to' => (is => 'ro', isa => 'Str');
33 after 'install_accessors' => sub {
35 $self->associated_class->add_method(
37 $self->get_read_method_ref
47 metaclass => 'My::Meta::Attribute::DefaultReadOnly',
48 traits => [qw/My::Attribute::Trait/],
54 my $c = My::Class->new(bar => 100);
55 isa_ok($c, 'My::Class');
57 is($c->bar, 100, '... got the right value for bar');
60 is($c->baz, 100, '... got the right value for baz');
62 isa_ok($c->meta->get_attribute('bar'), 'My::Meta::Attribute::DefaultReadOnly');
63 does_ok($c->meta->get_attribute('bar'), 'My::Attribute::Trait');
64 is($c->meta->get_attribute('bar')->_is_metadata, 'ro', '... got the right metaclass customization');