line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MoopsX::ListObjects; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$MoopsX::ListObjects::VERSION = '0.003001'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
183646
|
use strict; use warnings FATAL => 'all'; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use parent 'Moops'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
67906
|
use List::Objects::WithUtils (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
9
|
1
|
|
|
1
|
|
987
|
use List::Objects::Types (); |
|
1
|
|
|
|
|
155771
|
|
|
1
|
|
|
|
|
36
|
|
10
|
1
|
|
|
1
|
|
6304
|
use Type::Registry (); |
|
1
|
|
|
|
|
79643
|
|
|
1
|
|
|
|
|
472
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
1
|
|
|
1
|
|
81
|
my ($class, %params) = @_; |
14
|
1
|
|
|
|
|
2
|
push @{ $params{imports} }, |
|
1
|
|
|
|
|
9
|
|
15
|
|
|
|
|
|
|
'List::Objects::Types' => [ -all ], |
16
|
|
|
|
|
|
|
'List::Objects::WithUtils' => [ qw/ |
17
|
|
|
|
|
|
|
array immarray array_of immarray_of |
18
|
|
|
|
|
|
|
hash hash_of immhash immhash_of |
19
|
|
|
|
|
|
|
/ ], |
20
|
|
|
|
|
|
|
; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
4
|
my $pkg = caller; |
23
|
1
|
|
|
|
|
5
|
Type::Registry->for_class($pkg)->add_types('List::Objects::Types'); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
2506
|
for my $tname (List::Objects::Types->type_names) { |
26
|
9
|
|
|
|
|
372
|
my $reg = Type::Registry->for_class($pkg); |
27
|
9
|
50
|
|
|
|
68
|
$reg->add_type( List::Objects::Types->get_type($tname) ) |
28
|
|
|
|
|
|
|
unless $reg->simple_lookup($tname) |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
101
|
@_ = ( $class, %params ); |
32
|
1
|
|
|
|
|
13
|
goto \&Moops::import |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=for Pod::Coverage import |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
MoopsX::ListObjects - Use Moops with List::Objects::WithUtils |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
package My::App; |
48
|
|
|
|
|
|
|
use MoopsX::ListObjects; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
class Foo { |
51
|
|
|
|
|
|
|
has mylist => ( |
52
|
|
|
|
|
|
|
default => sub { array }, |
53
|
|
|
|
|
|
|
isa => ArrayObj |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has mydata => ( |
57
|
|
|
|
|
|
|
default => sub { +{} }, |
58
|
|
|
|
|
|
|
isa => HashObj, |
59
|
|
|
|
|
|
|
coerce => 1 |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
method add_items (@items) { |
63
|
|
|
|
|
|
|
$self->mylist->push(@items) |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
method find_matches (Str $string) { |
67
|
|
|
|
|
|
|
$self->mylist->grep(sub { $_ eq $string }) |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $foo = Foo->new; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$foo->add_items(qw/ foo bar baz /); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $matches = $foo->find_matches( 'foo' ); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 DESCRIPTION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Extends Toby Inkster's L<Moops> sugary class building syntax with |
80
|
|
|
|
|
|
|
L<List::Objects::WithUtils> objects. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Importing L<MoopsX::ListObjects> is the same as importing L<Moops>, but with |
83
|
|
|
|
|
|
|
all of the objects available from L<List::Objects::WithUtils>, as well as the |
84
|
|
|
|
|
|
|
types and coercions from L<List::Objects::Types>. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L<Moops> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
L<List::Objects::WithUtils> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L<List::Objects::Types> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
L<List::Objects::WithUtils::Role::Array> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
L<List::Objects::WithUtils::Role::Hash> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Jon Portnoy <avenj@cobaltirc.org> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |