6 use Test::More 'no_plan';
9 use_ok('Moose::Policy');
13 package My::Moose::Meta::Attribute;
16 extends 'Moose::Meta::Attribute';
18 # this method (mostly stolen from M::M::Attribute) just rebuilds the
19 # options so anything with 'is' gets PBP accessors
20 sub _process_options {
21 my ($class, $name, $options) = @_;
22 if (exists $options->{is}) {
23 if ($options->{is} eq 'ro') {
24 $options->{reader} = 'get_' . $name;
26 elsif ($options->{is} eq 'rw') {
27 $options->{reader} = 'get_' . $name;
28 $options->{writer} = 'set_' . $name;
30 delete $options->{is};
33 $class->SUPER::_process_options($name, $options);
38 package My::Moose::Policy;
39 # policy just specifies metaclass delegates
40 use constant attribute_metaclass => 'My::Moose::Meta::Attribute';
46 use Moose::Policy 'My::Moose::Policy';
49 has 'bar' => (is => 'rw', default => 'Foo::bar');
50 has 'baz' => (is => 'ro', default => 'Foo::baz');
53 isa_ok(Foo->meta, 'Moose::Meta::Class');
54 is(Foo->meta->attribute_metaclass, 'My::Moose::Meta::Attribute', '... got our custom attr metaclass');
56 isa_ok(Foo->meta->get_attribute('bar'), 'My::Moose::Meta::Attribute');
61 can_ok($foo, 'get_bar');
62 can_ok($foo, 'set_bar');
64 can_ok($foo, 'get_baz');
66 is($foo->get_bar, 'Foo::bar', '... got the right default value');
67 is($foo->get_baz, 'Foo::baz', '... got the right default value');