X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FEmail.pm;h=bb304cfb41906f1bce7806d91010cbfbe8785234;hb=d0e11256c36f5cd0c4a93e973f14c32197466336;hp=e274daa7fd42a0d3259febef97f9b17d2806af24;hpb=43090696b9cc6002e258a76a3f9004daa48631fe;p=catagits%2FCatalyst-View-Email.git diff --git a/lib/Catalyst/View/Email.pm b/lib/Catalyst/View/Email.pm index e274daa..bb304cf 100644 --- a/lib/Catalyst/View/Email.pm +++ b/lib/Catalyst/View/Email.pm @@ -11,7 +11,7 @@ use Email::MIME::Creator; use base qw/ Catalyst::View /; -our $VERSION = '0.09999_01'; +our $VERSION = '0.09999_02'; __PACKAGE__->mk_accessors(qw/ mailer /); @@ -182,7 +182,7 @@ sub process { my $email = $c->stash->{$self->{stash_key}}; croak "Can't send email without a valid email structure" unless $email; - + if ( exists $self->{content_type} ) { $email->{content_type} ||= $self->{content_type}; } @@ -222,7 +222,7 @@ sub process { $mime{attributes}->{charset} = $self->{default}->{charset}; } - my $message = $self->generate_part( \%mime ); + my $message = $self->generate_message( $c, \%mime ); #my $message = Email::MIME->create(%mime); @@ -243,9 +243,11 @@ sub setup_attributes { my $e_m_attrs = {}; if (exists $attrs->{content_type} && defined $attrs->{content_type} && $attrs->{content_type} ne '') { + $c->log->debug('C::V::Email uses specified content_type ' . $attrs->{content_type} . '.') if $c->debug; $e_m_attrs->{content_type} = $attrs->{content_type}; } elsif (defined $default_content_type && $default_content_type ne '') { + $c->log->debug("C::V::Email uses default content_type $default_content_type.") if $c->debug; $e_m_attrs->{content_type} = $default_content_type; } @@ -259,11 +261,11 @@ sub setup_attributes { return $e_m_attrs; } -sub generate_part { - my ( $self, $attr ) = @_; +sub generate_message { + my ( $self, $c, $attr ) = @_; # setup the attributes (merge with defaults) - $attr->{attributes} = $self->setup_attributes($attr->{attributes}); + $attr->{attributes} = $self->setup_attributes($c, $attr->{attributes}); return Email::MIME->create(%$attr); }