use Test::More 'no_plan';
BEGIN {
- use_ok('Moose::Policy');
+ use_ok('Moose::Policy');
}
{
package My::Moose::Meta::Attribute;
use Moose;
-
+
extends 'Moose::Meta::Attribute';
-
+
# this method (mostly stolen from M::M::Attribute) just rebuilds the
# options so anything with 'is' gets PBP accessors
sub _process_options {
my ($class, $name, $options) = @_;
- if (exists $options->{is}) {
- if ($options->{is} eq 'ro') {
- $options->{reader} = 'get_' . $name;
- }
- elsif ($options->{is} eq 'rw') {
- $options->{reader} = 'get_' . $name;
- $options->{writer} = 'set_' . $name;
- }
- delete $options->{is};
- }
-
+ if (exists $options->{is}) {
+ if ($options->{is} eq 'ro') {
+ $options->{reader} = 'get_' . $name;
+ }
+ elsif ($options->{is} eq 'rw') {
+ $options->{reader} = 'get_' . $name;
+ $options->{writer} = 'set_' . $name;
+ }
+ delete $options->{is};
+ }
+
$class->SUPER::_process_options($name, $options);
}
}
{
package Foo;
-
+
use Moose::Policy 'My::Moose::Policy';
use Moose;
-
+
has 'bar' => (is => 'rw', default => 'Foo::bar');
has 'baz' => (is => 'ro', default => 'Foo::baz');
}
is($foo->get_bar, 'Foo::bar', '... got the right default value');
is($foo->get_baz, 'Foo::baz', '... got the right default value');
-
-
-
-
+# vim:ts=4:sw=4:et:sta