From: Stevan Little Date: Fri, 12 May 2006 15:44:26 +0000 (+0000) Subject: foo X-Git-Tag: 0_09_03~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=74f6d830e86967e28a6c072e10732b13d8d00e71;p=gitmo%2FMoose.git foo --- diff --git a/lib/Moose.pm b/lib/Moose.pm index 3e3ff10..eaf420c 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -131,7 +131,17 @@ use Moose::Util::TypeConstraints; my $inherited_attr = $meta->find_attribute_by_name($1); (defined $inherited_attr) || confess "Could not find an attribute by the name of '$1' to inherit from"; - my $new_attr = $inherited_attr->clone_and_inherit_options(%options); + my $new_attr; + if ($inherited_attr->isa('Moose::Meta::Attribute')) { + $new_attr = $inherited_attr->clone_and_inherit_options(%options); + } + else { + # NOTE: + # kind of a kludge to handle Class::MOP::Attributes + $new_attr = Moose::Meta::Attribute::clone_and_inherit_options( + $inherited_attr, %options + ); + } $meta->add_attribute($new_attr); } else { diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 47c32db..03e00ad 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -39,6 +39,7 @@ sub does_role { (defined $role_name) || confess "You must supply a role name to look for"; foreach my $class ($self->class_precedence_list) { + next unless $class->can('meta'); foreach my $role (@{$class->meta->roles}) { return 1 if $role->does_role($role_name); } @@ -50,7 +51,8 @@ sub excludes_role { my ($self, $role_name) = @_; (defined $role_name) || confess "You must supply a role name to look for"; - foreach my $class ($self->class_precedence_list) { + foreach my $class ($self->class_precedence_list) { + next unless $class->can('meta'); foreach my $role (@{$class->meta->roles}) { return 1 if $role->excludes_role($role_name); } @@ -76,7 +78,7 @@ sub construct_instance { # but this is foreign inheritence, so we might # have to kludge it in the end. my $instance = $params{'__INSTANCE__'} || $meta_instance->create_instance(); - foreach my $attr ($class->compute_all_applicable_attributes()) { + foreach my $attr ($class->compute_all_applicable_attributes()) { $attr->initialize_instance_slot($meta_instance, $instance, \%params) } return $instance;