Subject: | Email::Send 2 not backwards compatible enough when not importing |
(This is an RT-ified version of the patch I emailed Casey in February 2006.)
Prior to version 2, Email::Send could be used and not imported, which is
an important property. One could call Email::Send::send. This broke
with 2.0, as send only works the way it did in 1.x, now, when it is
exported.
This patch fixes that.
--
rjbs
Subject: | es-no-import.patch |
diff -Nur Email-Send-2.04/lib/Email/Send.pm Email-Send-no-import/lib/Email/Send.pm
--- Email-Send-2.04/lib/Email/Send.pm 2006-01-28 18:02:44.000000000 -0500
+++ Email-Send-no-import/lib/Email/Send.pm 2006-02-04 10:00:35.000000000 -0500
@@ -129,7 +129,9 @@
=cut
sub send {
+ goto &_send_function unless eval { $_[0]->isa('Email::Send') };
my ($self, $message, @args) = @_;
+
my $simple = $self->_objectify_message($message);
return failure "No message found." unless $simple;
diff -Nur Email-Send-2.04/t/lib/Email/Send/OK.pm Email-Send-no-import/t/lib/Email/Send/OK.pm
--- Email-Send-2.04/t/lib/Email/Send/OK.pm 1969-12-31 19:00:00.000000000 -0500
+++ Email-Send-no-import/t/lib/Email/Send/OK.pm 2006-02-04 10:00:04.000000000 -0500
@@ -0,0 +1,14 @@
+package Email::Send::OK;
+
+use Test::More;
+
+use strict;
+use warnings;
+
+sub is_available { 1 }
+
+sub send {
+ ok(1, "send message $_[0]");
+}
+
+1;
diff -Nur Email-Send-2.04/t/no-import.t Email-Send-no-import/t/no-import.t
--- Email-Send-2.04/t/no-import.t 1969-12-31 19:00:00.000000000 -0500
+++ Email-Send-no-import/t/no-import.t 2006-02-04 09:54:11.000000000 -0500
@@ -0,0 +1,20 @@
+#!perl
+use strict;
+use warnings;
+
+use lib 't/lib';
+
+use Test::More 'no_plan';
+
+BEGIN { use_ok('Email::Send', ()); }
+
+my $message = <<'.';
+To: casey@geeknest.com
+From: foo@example.com
+
+Blah
+.
+
+my $rv = Email::Send::send OK => $message;
+
+ok($rv, "sender reports success");