| 1 | package Sietima::Types; | ||
| 2 | 19 | ▶ | use Sietima::Policy; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 19 | ▶ | use Type::Utils -all; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 19 | ▶ | use Types::Standard qw(Str HashRef Defined Str); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 19 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | use Type::Library | ||
| 7 | 19 | ▶ | -base, |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | -declare => qw(SietimaObj | ||
| 9 | Address AddressFromStr | ||
| 10 | TagName | ||
| 11 | EmailMIME Message | ||
| 12 | HeaderUri HeaderUriFromThings | ||
| 13 | Subscriber SubscriberFromAddress SubscriberFromStr SubscriberFromHashRef | ||
| 14 | 19 | Transport MailStore MailStoreFromHashRef); | |
| 15 | |||
| 16 | 19 | our $VERSION = '1.1.5'; # VERSION | |
| 17 | # ABSTRACT: type library for Sietima | ||
| 18 | |||
| 19 | |||
| 20 | 19 | class_type SietimaObj, { class => 'Sietima' }; | |
| 21 | |||
| 22 | |||
| 23 | 19 | class_type EmailMIME, { class => 'Email::MIME' }; | |
| 24 | |||
| 25 | |||
| 26 | 19 | role_type Transport, { role => 'Email::Sender::Transport' }; | |
| 27 | |||
| 28 | |||
| 29 | 19 | role_type MailStore, { role => 'Sietima::MailStore' }; | |
| 30 | |||
| 31 | 19 | declare_coercion MailStoreFromHashRef, | |
| 32 | to_type MailStore, from HashRef, | ||
| 33 | q{ require Module::Runtime; } . | ||
| 34 | q{ Module::Runtime::use_module(delete $_->{class})->new($_); }; | ||
| 35 | |||
| 36 | |||
| 37 | 19 | class_type Address, { class => 'Email::Address' }; | |
| 38 | 19 | declare_coercion AddressFromStr, | |
| 39 | to_type Address, from Str, | ||
| 40 | q{ (Email::Address->parse($_))[0] }; | ||
| 41 | |||
| 42 | |||
| 43 | declare TagName, as Str, | ||
| 44 | 0 | ▶ | where { /\A\w+\z/ }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 45 | 88 | ▶ | inline_as sub($constraint,$varname,@){ |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 46 | 88 | $constraint->parent->inline_check($varname) | |
| 47 | .qq{ && ($varname =~/\\A\\w+\\z/) }; | ||
| 48 | 19 | }; | |
| 49 | |||
| 50 | |||
| 51 | 19 | class_type Message, { class => 'Sietima::Message' }; | |
| 52 | |||
| 53 | 19 | class_type HeaderUri, { class => 'Sietima::HeaderURI' }; | |
| 54 | |||
| 55 | 19 | declare_coercion HeaderUriFromThings, | |
| 56 | to_type HeaderUri, from Defined, | ||
| 57 | q{ Sietima::HeaderURI->new($_) }; | ||
| 58 | |||
| 59 | |||
| 60 | 19 | class_type Subscriber, { class => 'Sietima::Subscriber' }; | |
| 61 | |||
| 62 | 19 | declare_coercion SubscriberFromAddress, | |
| 63 | to_type Subscriber, from Address, | ||
| 64 | q{ Sietima::Subscriber->new(primary=>$_) }; | ||
| 65 | |||
| 66 | 19 | declare_coercion SubscriberFromStr, | |
| 67 | to_type Subscriber, from Str, | ||
| 68 | q{ Sietima::Subscriber->new(primary=>(Email::Address->parse($_))[0]) }; | ||
| 69 | |||
| 70 | 19 | declare_coercion SubscriberFromHashRef, | |
| 71 | to_type Subscriber, from HashRef, | ||
| 72 | q{ Sietima::Subscriber->new($_) }; | ||
| 73 | |||
| 74 | 19 | 1; | |
| 75 | |||
| 76 | __END__ | ||