File Coverage

blib/lib/WebService/Toggl/Role/Set.pm
Criterion Covered Total %
statement 3 11 27.2
branch n/a
condition n/a
subroutine 1 3 33.3
pod n/a
total 4 14 28.5


line stmt bran cond sub pod time code
1             package WebService::Toggl::Role::Set;
2              
3 1     1   459 use Moo::Role;
  1         2  
  1         5  
4             with 'WebService::Toggl::Role::Base';
5              
6             requires 'list_of';
7              
8             has raw => (is => 'ro', lazy => 1, builder => 1);
9             sub _build_raw {
10 0     0     my ($self) = @_;
11 0           my $response = $self->api_get( $self->my_url );
12 0           return $response->data;
13             }
14              
15              
16             sub all {
17 0     0     my ($self) = @_;
18 0           my $new_class = $self->list_of;
19 0           return map { $self->new_item_from_raw($new_class, $_) } @{$self->raw};
  0            
  0            
20             }
21              
22              
23             1;
24             __END__
25              
26             =encoding utf-8
27              
28             =head1 NAME
29              
30             WebService::Toggl::Role::Set - Common behavior for Sets of API objects
31              
32             =head1 DESCRIPTION
33              
34             This role provide behavior common to all Sets of
35             C<WebService::Toggl::API::> objects.
36              
37             =head1 REQUIRES
38              
39             =head2 list_of
40              
41             The class name of the objects this set comprises.
42              
43             =head1 ATTRIBUTES
44              
45             =head2 raw
46              
47             The raw data returned from query the collection endpoint.
48              
49             =head1 METHODS
50              
51             =head2 all
52              
53             Returns a list of objects in the set. The objects are constructed
54             from the raw data in the Set, so no additional queries are necessary.
55              
56             =head1 LICENSE
57              
58             Copyright (C) Fitz Elliott.
59              
60             This library is free software; you can redistribute it and/or modify
61             it under the same terms as Perl itself.
62              
63             =head1 AUTHOR
64              
65             Fitz Elliott E<lt>felliott@fiskur.orgE<gt>
66              
67             =cut
68