# New Ticket Created by Flavio Poletti
# Please include the string: [perl #49202]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=49202 >
Hi,
I encountered a couple of problems with lib/SmartLinks.pm. In
particular, its implementation breaks with the current Moose/Class::MOP
versions.
First of all, "undef" is no longer an acceptable value for something that
has an 'isa' that does not allow it. And 'undef' can't be regarded as a
valid Keyphrase object.
Moreover, as of version 0.43 of Class::MOP, the predicate methods do not
work any more as they were documented (and as they're still documented in
0.50, but it will be in the next release I think). To be brief, the
predicate method now checks for the existence of any value for a given
attribute, not its definedness.
I'm attaching a patch that addresses both concerns, I hope you'll find it
useful. Be warned that if you take it, you'll be forced to upgrade at
least to the current version of Moose (0.33) and Class::MOP (0.50).
Best regards,
Flavio Poletti.
--- lib/SmartLink.pm 2007-12-29 15:52:38.000000000 +0100
+++ lib/SmartLink.pm.new 2007-12-29 17:09:35.251666784 +0100
@@ -29,13 +29,17 @@
has 'keyphrases' => (
is => 'ro', isa => 'Keyphrase',
- default => sub{
- ($_)= shift->link =~ m|^L<.*?/.*?/([^>]+)>|;
- defined $_ ? Keyphrase->new( string => $_ ) : undef;
- },
predicate => 'has_keyphrases',
);
+sub BUILD { # Set a value for keyphrases *only* if there is any
+ my $self = shift;
+ my ($keyphrase)= $self->link =~ m|^L<.*?/.*?/([^>]+)>|;
+ $self->meta->find_attribute_by_name("keyphrases")->set_value(
+ $self, Keyphrase->new(string => $keyphrase)
+ ) if defined $keyphrase;
+ return;
+}
package Doc;
use Moose;
--- CREDITS 2007-12-29 17:53:28.792307752 +0100
+++ CREDITS.new 2007-12-29 17:53:20.252605984 +0100
@@ -211,6 +211,9 @@
N: Felix Gallo
D: delegate.pmc patch
+N: Flavio Poletti
+D: SmartLink patch for Moose after 0.43
+
N: Florian Ragwitz
E: [EMAIL PROTECTED]
W: http://www.tu-chemnitz.de/~rafl/