line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Types::LaxNum; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
432994
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
5
|
1
|
|
|
1
|
|
6143429
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
17216045
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
1747
|
use Scalar::Util qw( looks_like_number ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
199
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: A LaxNum type which provides the loose behavior of Moose's Num pre-2.10 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $value_type = Moose::Util::TypeConstraints::find_type_constraint('Value'); |
10
|
|
|
|
|
|
|
subtype 'LaxNum' |
11
|
|
|
|
|
|
|
=> as 'Str' |
12
|
|
|
|
|
|
|
=> where { Scalar::Util::looks_like_number($_) } |
13
|
|
|
|
|
|
|
=> inline_as { |
14
|
|
|
|
|
|
|
# the long Str tests are redundant here |
15
|
|
|
|
|
|
|
$value_type->_inline_check($_[1]) |
16
|
|
|
|
|
|
|
. ' && Scalar::Util::looks_like_number(' . $_[1] . ')' |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=pod |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
MooseX::Types::LaxNum - A LaxNum type which provides the loose behavior of Moose's Num pre-2.10 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 VERSION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
version 0.04 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#!/usr/bin/env perl |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use strict; |
38
|
|
|
|
|
|
|
use warnings; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
package Foo { |
41
|
|
|
|
|
|
|
use Moose; |
42
|
|
|
|
|
|
|
use MooseX::Types::LaxNum; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'laxnum', is => 'rw', isa => 'LaxNum'; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $foo = Foo->new( laxnum => '1234' ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
C<LaxNum> accepts everything for which L<Scalar::Util/looks_like_number> return true. |
52
|
|
|
|
|
|
|
It can be used to get the old behaviour of C<Moose::Util::TypeConstraints::Num>, |
53
|
|
|
|
|
|
|
since Num has been changed to be more strict. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
MooseX::Types::LaxNum |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Copyright 2013 Upasana Shukla. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
64
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 AUTHOR |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Upasana Shukla <me@upasana.me> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Upasana Shukla. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
75
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |