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 {
(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);
}
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);
}
# 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;