From: Stevan Little Date: Mon, 9 Apr 2007 16:35:22 +0000 (+0000) Subject: foo X-Git-Tag: 0_21~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac0ece3dc42ae7e0402a46eb25dbdc57f6cbcc9b;p=gitmo%2FMoose.git foo --- diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 3da2d89..c35f7cd 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -9,7 +9,7 @@ use Carp 'confess'; use Scalar::Util 'blessed'; use B 'svref_2object'; -our $VERSION = '0.06'; +our $VERSION = '0.07'; our $AUTHORITY = 'cpan:STEVAN'; use Moose::Meta::Class; @@ -367,10 +367,20 @@ sub _apply_attributes { } } else { - $other->add_attribute( - $attribute_name, - $self->get_attribute($attribute_name) - ); + # NOTE: + # this is kinda ugly ... + if ($other->isa('Moose::Meta::Class')) { + $other->_process_attribute( + $attribute_name, + %{$self->get_attribute($attribute_name)} + ); + } + else { + $other->add_attribute( + $attribute_name, + $self->get_attribute($attribute_name) + ); + } } } } diff --git a/t/107_custom_attr_meta_with_roles.t b/t/107_custom_attr_meta_with_roles.t new file mode 100644 index 0000000..e22cf9b --- /dev/null +++ b/t/107_custom_attr_meta_with_roles.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 4; +use Test::Exception; + +BEGIN { + use_ok('Moose'); +} + +{ + package My::Custom::Meta::Attr; + use Moose; + + extends 'Moose::Meta::Attribute'; +} + +{ + package My::Fancy::Role; + use Moose::Role; + + has 'bling_bling' => ( + metaclass => 'My::Custom::Meta::Attr', + is => 'rw', + isa => 'Str', + ); +} + +{ + package My::Class; + use Moose; + + with 'My::Fancy::Role'; +} + +my $c = My::Class->new; +isa_ok($c, 'My::Class'); + +ok($c->meta->has_attribute('bling_bling'), '... got the attribute'); + +isa_ok($c->meta->get_attribute('bling_bling'), 'My::Custom::Meta::Attr'); + +