blib/lib/MooseX/Types/Stringlike.pm

filter: Statementstmt 100% 29 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 100% 38 / 38 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 2 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package MooseX::Types::Stringlike;
6 # ABSTRACT: Moose type constraints for strings or string-like objects
7 2 our $VERSION = '0.003'; # VERSION
8  
9 2 ▶use MooseX::Types -declare => [ qw/Stringable Stringlike ArrayRefOfStringable ArrayRefOfStringlike / ];
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use MooseX::Types::Moose qw/Str Object ArrayRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use overload ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Thanks ilmari for suggesting something like this
14 subtype Stringable,
15 as Object,
16 6 ▶ where { overload::Method($_, '""') };
Subroutine __ANON__: called CC=1 SCAR=0.0
17  
18 2 subtype Stringlike,
19 as Str;
20  
21 coerce Stringlike,
22 from Stringable,
23 1 ▶ via { "$_" };
Subroutine __ANON__: called CC=1 SCAR=0.0
24  
25  
26 2 subtype ArrayRefOfStringable,
27 as ArrayRef[Stringable];
28  
29 2 subtype ArrayRefOfStringlike,
30 as ArrayRef[Stringlike];
31  
32 coerce ArrayRefOfStringlike,
33 from ArrayRefOfStringable,
34 1 ▶ via { [ map { "$_" } @$_ ] };
Subroutine __ANON__: called CC=1 SCAR=0.0
35  
36 2 1;
37  
38  
39 # vim: ts=2 sts=2 sw=2 et:
40  
41 __END__
↑ Summary