Subject: | ShowClass plugin doesn't properly handle roles |
When require/use'ing new modules, ShowClass tries to display a summary of roles and fails. (use Net::GitHub causes the failure for me.) A patch to fix this is attached.
Subject: | 0001-ShowClass-Check-for-superclasses-before-calling-it.patch |
From bf6d0ae8b8774747ecd741c2bd845f3cb4c70933 Mon Sep 17 00:00:00 2001
From: Rob Hoelz <rob@hoelz.ro>
Date: Sun, 22 Dec 2013 18:30:13 -0600
Subject: [PATCH] ShowClass: Check for superclasses before calling it
Moose::Meta::Role doesn't define superclasses, so we check for the
superclasses method first.
---
lib/Devel/REPL/Plugin/ShowClass.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/Devel/REPL/Plugin/ShowClass.pm b/lib/Devel/REPL/Plugin/ShowClass.pm
index 6388c5b..ef9bb83 100644
--- a/lib/Devel/REPL/Plugin/ShowClass.pm
+++ b/lib/Devel/REPL/Plugin/ShowClass.pm
@@ -44,7 +44,7 @@ sub update_metaclass_cache {
sub display_class {
my ($self, $meta) = @_;
$self->print('package ' . $meta->name . ";\n\n");
- $self->print('extends (' . (join ", " => $meta->superclasses) . ");\n\n") if $meta->superclasses;
+ $self->print('extends (' . (join ", " => $meta->superclasses) . ");\n\n") if $meta->can('superclasses') && $meta->superclasses;
$self->print('with (' . (join ", " => map { $_->name } @{$meta->roles}) . ");\n\n") if $meta->can('roles');
foreach my $attr (map { $meta->get_attribute($_) } $meta->get_attribute_list) {
$self->print('has ' . $attr->name . " => (\n");
--
1.8.5.1