| 1 | package Example::Comb::Mailer::Stub; | ||
| 2 | # ABSTRACT: Example stub: a Mailpit instead of the SMTP relay | ||
| 3 | |||
| 4 | # A stub is a subclass: it inherits the contract of the Mailer -- the | ||
| 5 | # endpoint smtp, which the contract check at construction insists on -- and | ||
| 6 | # swaps the implementation. Here the implementation is a .pk8s file next to | ||
| 7 | # this module, loaded by Kubernetes::Comb::Role::Static; a distribution of | ||
| 8 | # Comb classes would keep it in its share dir (File::ShareDir's dist_dir). | ||
| 9 | |||
| 10 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 1 | extends 'Example::Comb::Mailer'; | |
| 12 | 1 | with 'Kubernetes::Comb::Role::Static'; | |
| 13 | |||
| 14 | 1 | ▶ | use Path::Tiny qw( path ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | 1 | ▶ | sub manifest_dir { path(__FILE__)->absolute->parent } |
|
Subroutine
manifest_dir: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 18 | 1 | ▶ | sub manifest_files { 'Stub.pk8s' } |
|
Subroutine
manifest_files: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 19 | |||
| 20 | # Mailpit catches every mail: no relay, nothing to configure. | ||
| 21 | 1 | ▶ | sub check { return } |
|
Subroutine
check: called CC=1 SCAR=0.0
Pod
documented
| |||
| 22 | |||
| 23 | # A stub may offer more than its original: Mailpit's web interface. | ||
| 24 | 1 | ▶ | around endpoints => sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 25 | 1 | my ( $orig, $self ) = @_; | |
| 26 | 1 | return ( $self->$orig, { name => 'web', port => 8025 } ); | |
| 27 | 1 | }; | |
| 28 | |||
| 29 | 1 | 1; | |