aboutsummaryrefslogtreecommitdiff
path: root/lib/Sietima/Role/SubjectTag.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sietima/Role/SubjectTag.pm')
-rw-r--r--lib/Sietima/Role/SubjectTag.pm73
1 files changed, 51 insertions, 22 deletions
diff --git a/lib/Sietima/Role/SubjectTag.pm b/lib/Sietima/Role/SubjectTag.pm
index 7602405..b6b9159 100644
--- a/lib/Sietima/Role/SubjectTag.pm
+++ b/lib/Sietima/Role/SubjectTag.pm
@@ -4,9 +4,44 @@ use Sietima::Policy;
use Types::Standard qw(Str);
use namespace::clean;
-# VERSION
+our $VERSION = '1.1.2'; # VERSION
# ABSTRACT: add a tag to messages' subjects
+
+has subject_tag => (
+ is => 'ro',
+ isa => Str,
+ required => 1,
+);
+
+
+around munge_mail => sub ($orig,$self,$mail) {
+ my $tag = '['.$self->subject_tag.']';
+ my $subject = $mail->header_str('Subject');
+ unless ($subject =~ m{\Q$tag\E}) {
+ $mail->header_str_set(
+ Subject => "$tag $subject",
+ );
+ }
+ return $self->$orig($mail);
+};
+
+1;
+
+__END__
+
+=pod
+
+=encoding UTF-8
+
+=head1 NAME
+
+Sietima::Role::SubjectTag - add a tag to messages' subjects
+
+=head1 VERSION
+
+version 1.1.2
+
=head1 SYNOPSIS
my $sietima = Sietima->with_traits('SubjectTag')->new({
@@ -19,7 +54,9 @@ use namespace::clean;
A L<< C<Sietima> >> list with this role applied will prepend the given
tag to every outgoing message's C<Subject:> header.
-=attr C<subject_tag>
+=head1 ATTRIBUTES
+
+=head2 C<subject_tag>
Required string. This string, enclosed by square brackets, will be
prepended to the C<Subject:> header of outgoing messages. For example,
@@ -30,30 +67,22 @@ If the incoming message's C<Subject:> header already contains the tag,
the header will not be modified. This prevents getting subjects like
"[foo] Re: [foo] Re: [foo] new stuff".
-=cut
+=head1 MODIFIED METHODS
-has subject_tag => (
- is => 'ro',
- isa => Str,
- required => 1,
-);
-
-=modif C<munge_mail>
+=head2 C<munge_mail>
The subject of the incoming email is modified to add the tag (unless
it's already there). The email is then processed normally.
-=cut
+=head1 AUTHOR
-around munge_mail => sub ($orig,$self,$mail) {
- my $tag = '['.$self->subject_tag.']';
- my $subject = $mail->header_str('Subject');
- unless ($subject =~ m{\Q$tag\E}) {
- $mail->header_str_set(
- Subject => "$tag $subject",
- );
- }
- return $self->$orig($mail);
-};
+Gianni Ceccarelli <dakkar@thenautilus.net>
-1;
+=head1 COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2023 by Gianni Ceccarelli <dakkar@thenautilus.net>.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=cut