11 package Foo::Meta::Attribute;
14 extends 'Moose::Meta::Attribute';
20 $next->($self, $name, (is => 'rw', isa => 'Foo'), @_);
26 has 'foo' => (metaclass => 'Foo::Meta::Attribute');
32 my $foo_attr = Foo->meta->get_attribute('foo');
33 isa_ok($foo_attr, 'Foo::Meta::Attribute');
34 isa_ok($foo_attr, 'Moose::Meta::Attribute');
36 is($foo_attr->name, 'foo', '... got the right name for our meta-attribute');
37 ok($foo_attr->has_accessor, '... our meta-attrubute created the accessor for us');
39 ok($foo_attr->has_type_constraint, '... our meta-attrubute created the type_constraint for us');
41 my $foo_attr_type_constraint = $foo_attr->type_constraint;
42 isa_ok($foo_attr_type_constraint, 'Moose::Meta::TypeConstraint');
44 is($foo_attr_type_constraint->name, 'Foo', '... got the right type constraint name');
45 is($foo_attr_type_constraint->parent->name, 'Object', '... got the right type constraint parent name');
48 package Bar::Meta::Attribute;
51 extends 'Class::MOP::Attribute';
57 has 'bar' => (metaclass => 'Bar::Meta::Attribute');
58 }, '... the attribute metaclass need not be a Moose::Meta::Attribute as long as it behaves';
62 package Moose::Meta::Attribute::Custom::Foo;
63 sub register_implementation { 'Foo::Meta::Attribute' }
65 package Moose::Meta::Attribute::Custom::Bar;
68 extends 'Moose::Meta::Attribute';
74 has 'foo' => (metaclass => 'Foo');
75 }, '... the attribute metaclass alias worked correctly';
78 has 'bar' => (metaclass => 'Bar', is => 'bare');
79 }, '... the attribute metaclass alias worked correctly';
83 my $foo_attr = Another::Foo->meta->get_attribute('foo');
84 isa_ok($foo_attr, 'Foo::Meta::Attribute');
85 isa_ok($foo_attr, 'Moose::Meta::Attribute');
87 my $bar_attr = Another::Foo->meta->get_attribute('bar');
88 isa_ok($bar_attr, 'Moose::Meta::Attribute::Custom::Bar');
89 isa_ok($bar_attr, 'Moose::Meta::Attribute');