line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Perl::Collection::Array::MooseLike; |
2
|
|
|
|
|
|
|
$Data::Perl::Collection::Array::MooseLike::VERSION = '0.001008'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Collection::Array subclass that simulates Moose's native traits. |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
441
|
use strictures 1; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
412
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
173
|
|
|
1
|
|
|
|
|
49
|
|
8
|
1
|
|
|
1
|
|
359
|
use Class::Method::Modifiers; |
|
1
|
|
|
|
|
939
|
|
|
1
|
|
|
|
|
104
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Data::Perl::Role::Collection::Array'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
around 'splice' => sub { |
13
|
|
|
|
|
|
|
my $orig = shift; |
14
|
|
|
|
|
|
|
my @res = $orig->(@_); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# support both class instance method invocation style |
17
|
|
|
|
|
|
|
@res = blessed($res[0]) && $res[0]->isa('Data::Perl::Collection::Array') ? $res[0]->flatten : @res; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
wantarray ? @res : $res[-1]; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=pod |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=encoding UTF-8 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Data::Perl::Collection::Array::MooseLike - Collection::Array subclass that simulates Moose's native traits. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 VERSION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
version 0.001008 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use Data::Perl::Collection::Array::MooseLike; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $array = Data::Perl::Collection::Array::MooseLike->new(qw/a b c d/); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $scalar_context = $array->splice(0, 2); # removes and returns b |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my @list_context = $array->splice(0, 2); # returns and removes (b, c) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This class provides a wrapper and methods for interacting with an array. All |
49
|
|
|
|
|
|
|
methods are written to emulate/match existing behavior that exists with Moose's |
50
|
|
|
|
|
|
|
native traits. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DIFFERENCES IN FUNCTIONALITY |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item B |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Just like Perl's builtin splice. In scalar context, this returns the last |
59
|
|
|
|
|
|
|
element removed, or undef if no elements were removed. In list context, this |
60
|
|
|
|
|
|
|
returns all the elements removed from the array. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This method requires at least one argument. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SEE ALSO |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over 4 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * L |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * L |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Matthew Phillips |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Matthew Phillips . |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
85
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |