From 01e2190a635a2f158db40914f7f4cff86ca9a211 Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 12 Feb 2009 20:36:58 -0800 Subject: [PATCH] Revert "Add notes to Qpsmtpd::Address class" This reverts commit ea86b9fdb242be7b4aca8a5acfec6ad30360fc9f. Jared said... I originally considered these functionally identical, but they are not. The new code, called with, say, $txn->notes('discard',undef), would result in evaluation as if it were a 'get' method rather than setting the 'discard' note to undef. That seems quite dangerous. I suggest either reverting the language back to the '@_ and' model, or else doing something like: --- lib/Qpsmtpd/Address.pm | 14 -------------- lib/Qpsmtpd/Connection.pm | 11 +++++------ lib/Qpsmtpd/Transaction.pm | 8 +++++--- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/lib/Qpsmtpd/Address.pm b/lib/Qpsmtpd/Address.pm index ca9cdb3..71558bd 100644 --- a/lib/Qpsmtpd/Address.pm +++ b/lib/Qpsmtpd/Address.pm @@ -317,20 +317,6 @@ sub host { return $self->{_host}; } -=head2 notes($key[,$value]) - -Get or set a note on the recipient. This is a piece of data that you wish -to attach to the recipient and read somewhere else. For example you can -use this to pass data between plugins. - -=cut - -sub notes { - my ($self,$key,$value) = @_; - $self->{_notes}->{$key} = $value if defined $value; - return $self->{_notes}->{$key}; -} - sub _addr_cmp { require UNIVERSAL; my ($left, $right, $swap) = @_; diff --git a/lib/Qpsmtpd/Connection.pm b/lib/Qpsmtpd/Connection.pm index aade8e7..b12bbb5 100644 --- a/lib/Qpsmtpd/Connection.pm +++ b/lib/Qpsmtpd/Connection.pm @@ -108,9 +108,10 @@ sub hello_host { } sub notes { - my ($self,$key,$value) = @_; - $self->{_notes}->{$key} = $value if defined $value; - return $self->{_notes}->{$key}; + my $self = shift; + my $key = shift; + @_ and $self->{_notes}->{$key} = shift; + $self->{_notes}->{$key}; } sub reset { @@ -199,9 +200,7 @@ set after a successful return from those hooks. =head2 notes($key [, $value]) -Get or set a note on the transaction. This is a piece of data that you wish -to attach to the transaction and read somewhere else. For example you can -use this to pass data between plugins. +Connection-wide notes, used for passing data between plugins. =head2 clone([%args]) diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index 45d0350..c8ed194 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -55,9 +55,11 @@ sub header { #} sub notes { - my ($self,$key,$value) = @_; - $self->{_notes}->{$key} = $value if defined $value; - return $self->{_notes}->{$key}; + my $self = shift; + my $key = shift; + @_ and $self->{_notes}->{$key} = shift; + #warn Data::Dumper->Dump([\$self->{_notes}], [qw(notes)]); + $self->{_notes}->{$key}; } sub set_body_start {