File Coverage

blib/lib/LINQ/Array.pm
Criterion Covered Total %
statement 19 19 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 3 3 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1 57     57   2468 use 5.006;
  57         192  
2 57     57   302 use strict;
  57         97  
  57         1257  
3 57     57   285 use warnings;
  57         116  
  57         4320  
4              
5             if ( $] < 5.010000 ) {
6             require UNIVERSAL::DOES;
7             }
8              
9             package LINQ::Array;
10              
11             our $AUTHORITY = 'cpan:TOBYINK';
12             our $VERSION = '0.001';
13              
14 57     57   25767 use Role::Tiny::With ();
  57         284652  
  57         7187  
15              
16             Role::Tiny::With::with( qw( LINQ::Collection ) );
17              
18             sub new {
19 249     249 1 464 my $class = shift;
20 249         350 bless [ @{ $_[0] } ], $class;
  249         1695  
21             }
22              
23             sub count {
24 20     20 1 189 my $self = shift;
25 20 100       56 return $self->where( @_ )->count if @_;
26 19         131 scalar @$self;
27             }
28              
29             sub to_list {
30 309     309 1 444 my $self = shift;
31 309         1498 @$self;
32             }
33              
34             1;
35              
36             __END__
37              
38             =pod
39              
40             =encoding utf-8
41              
42             =head1 NAME
43              
44             LINQ::Array - a LINQ collection with an arrayref backend
45              
46             =head1 SYNOPSIS
47              
48             use LINQ qw( LINQ );
49             use LINQ::Array;
50            
51             my $linq = LINQ( [ 1 .. 3 ] );
52            
53             # Same:
54             my $linq = 'LINQ::Array'->new( [ 1 .. 3 ] );
55              
56             =head1 METHODS
57              
58             LINQ::Array supports all the methods defined in L<LINQ::Collection>.
59              
60             =begin trustme
61              
62             =item new
63              
64             =item count
65              
66             =item to_list
67              
68             =end trustme
69              
70             =head1 BUGS
71              
72             Please report any bugs to
73             L<http://rt.cpan.org/Dist/Display.html?Queue=LINQ>.
74              
75             =head1 SEE ALSO
76              
77             L<LINQ>, L<LINQ::Collection>.
78              
79             L<https://en.wikipedia.org/wiki/Language_Integrated_Query>
80              
81             =head1 AUTHOR
82              
83             Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
84              
85             =head1 COPYRIGHT AND LICENCE
86              
87             This software is copyright (c) 2021 by Toby Inkster.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =head1 DISCLAIMER OF WARRANTIES
93              
94             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
95             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
96             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.