aboutsummaryrefslogtreecommitdiff
path: root/lib/Sietima/Types.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sietima/Types.pm')
-rw-r--r--lib/Sietima/Types.pm157
1 files changed, 89 insertions, 68 deletions
diff --git a/lib/Sietima/Types.pm b/lib/Sietima/Types.pm
index c6c7381..8652501 100644
--- a/lib/Sietima/Types.pm
+++ b/lib/Sietima/Types.pm
@@ -13,39 +13,100 @@ use Type::Library
Subscriber SubscriberFromAddress SubscriberFromStr SubscriberFromHashRef
Transport MailStore MailStoreFromHashRef);
-# VERSION
+our $VERSION = '1.1.2'; # VERSION
# ABSTRACT: type library for Sietima
-=head1 DESCRIPTION
-This module is a L<< C<Type::Library> >>. It declares a few type
-constraints nad coercions.
+class_type SietimaObj, { class => 'Sietima' };
-=type C<SietimaObj>
-An instance of L<< C<Sietima> >>.
+class_type EmailMIME, { class => 'Email::MIME' };
-=cut
-class_type SietimaObj, { class => 'Sietima' };
+role_type Transport, { role => 'Email::Sender::Transport' };
-=type C<EmailMIME>
-An instance of L<< C<Email::MIME> >>.
+role_type MailStore, { role => 'Sietima::MailStore' };
-=cut
+declare_coercion MailStoreFromHashRef,
+ to_type MailStore, from HashRef,
+ q{ require Module::Runtime; } .
+ q{ Module::Runtime::use_module(delete $_->{class})->new($_); };
-class_type EmailMIME, { class => 'Email::MIME' };
-=type C<Transport>
+class_type Address, { class => 'Email::Address' };
+declare_coercion AddressFromStr,
+ to_type Address, from Str,
+ q{ (Email::Address->parse($_))[0] };
-An object that consumes the role L<< C<Email::Sender::Transport> >>.
-=cut
+declare TagName, as Str,
+ where { /\A\w+\z/ },
+ inline_as sub($constraint,$varname,@){
+ $constraint->parent->inline_check($varname)
+ .qq{ && ($varname =~/\\A\\w+\\z/) };
+ };
-role_type Transport, { role => 'Email::Sender::Transport' };
-=type C<MailStore>
+class_type Message, { class => 'Sietima::Message' };
+
+class_type HeaderUri, { class => 'Sietima::HeaderURI' };
+
+declare_coercion HeaderUriFromThings,
+ to_type HeaderUri, from Defined,
+q{ Sietima::HeaderURI->new($_) };
+
+
+class_type Subscriber, { class => 'Sietima::Subscriber' };
+
+declare_coercion SubscriberFromAddress,
+ to_type Subscriber, from Address,
+ q{ Sietima::Subscriber->new(primary=>$_) };
+
+declare_coercion SubscriberFromStr,
+ to_type Subscriber, from Str,
+ q{ Sietima::Subscriber->new(primary=>(Email::Address->parse($_))[0]) };
+
+declare_coercion SubscriberFromHashRef,
+ to_type Subscriber, from HashRef,
+ q{ Sietima::Subscriber->new($_) };
+
+1;
+
+__END__
+
+=pod
+
+=encoding UTF-8
+
+=head1 NAME
+
+Sietima::Types - type library for Sietima
+
+=head1 VERSION
+
+version 1.1.2
+
+=head1 DESCRIPTION
+
+This module is a L<< C<Type::Library> >>. It declares a few type
+constraints nad coercions.
+
+=head1 TYPES
+
+=head2 C<SietimaObj>
+
+An instance of L<< C<Sietima> >>.
+
+=head2 C<EmailMIME>
+
+An instance of L<< C<Email::MIME> >>.
+
+=head2 C<Transport>
+
+An object that consumes the role L<< C<Email::Sender::Transport> >>.
+
+=head2 C<MailStore>
An object that consumes the role L<< C<Sietima::MailStore> >>.
@@ -69,16 +130,7 @@ the C<%constructor_args>.
=back
-=cut
-
-role_type MailStore, { role => 'Sietima::MailStore' };
-
-declare_coercion MailStoreFromHashRef,
- to_type MailStore, from HashRef,
- q{ require Module::Runtime; } .
- q{ Module::Runtime::use_module(delete $_->{class})->new($_); };
-
-=type C<Address>
+=head2 C<Address>
An instance of L<< C<Email::Address> >>.
@@ -96,42 +148,16 @@ only the first one will be used.
=back
-=cut
-
-class_type Address, { class => 'Email::Address' };
-declare_coercion AddressFromStr,
- to_type Address, from Str,
- q{ (Email::Address->parse($_))[0] };
-
-=type C<TagName>
+=head2 C<TagName>
A string composed exclusively of "word" (C</\w/>) characters. Used by
L<mail stores|Sietima::MailStore> to tag messages.
-=cut
-
-declare TagName, as Str,
- where { /\A\w+\z/ },
- inline_as sub($constraint,$varname,@){
- $constraint->parent->inline_check($varname)
- .qq{ && ($varname =~/\\A\\w+\\z/) };
- };
-
-=type C<Message>
+=head2 C<Message>
An instance of L<< C<Sietima::Message> >>.
-=cut
-
-class_type Message, { class => 'Sietima::Message' };
-
-class_type HeaderUri, { class => 'Sietima::HeaderURI' };
-
-declare_coercion HeaderUriFromThings,
- to_type HeaderUri, from Defined,
-q{ Sietima::HeaderURI->new($_) };
-
-=type C<Subscriber>
+=head2 C<Subscriber>
An instance of L<< C<Sietima::Subscriber> >>.
@@ -162,20 +188,15 @@ passing it to the constructor.
=back
-=cut
+=head1 AUTHOR
-class_type Subscriber, { class => 'Sietima::Subscriber' };
+Gianni Ceccarelli <dakkar@thenautilus.net>
-declare_coercion SubscriberFromAddress,
- to_type Subscriber, from Address,
- q{ Sietima::Subscriber->new(primary=>$_) };
+=head1 COPYRIGHT AND LICENSE
-declare_coercion SubscriberFromStr,
- to_type Subscriber, from Str,
- q{ Sietima::Subscriber->new(primary=>(Email::Address->parse($_))[0]) };
+This software is copyright (c) 2023 by Gianni Ceccarelli <dakkar@thenautilus.net>.
-declare_coercion SubscriberFromHashRef,
- to_type Subscriber, from HashRef,
- q{ Sietima::Subscriber->new($_) };
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
-1;
+=cut