File Coverage

blib/lib/API/Instagram/Location.pm
Criterion Covered Total %
statement 17 17 100.0
branch 5 6 83.3
condition 2 4 50.0
subroutine 7 7 100.0
pod 1 1 100.0
total 32 35 91.4


line stmt bran cond sub pod time code
1             package API::Instagram::Location;
2              
3             # ABSTRACT: Instagram Location Object
4              
5 15     15   108 use Moo;
  15         31  
  15         103  
6 15     15   6149 use Carp;
  15         29  
  15         6577  
7              
8             has id => ( is => 'ro', predicate => 1 );
9             has latitude => ( is => 'lazy' );
10             has longitude => ( is => 'lazy' );
11             has name => ( is => 'lazy' );
12             has _data => ( is => 'rwp', lazy => 1, builder => 1, clearer => 1 );
13              
14              
15             sub recent_medias {
16 2     2 1 445 my $self = shift;
17              
18 2 100 50     147 carp "Not available for location with no ID." and return [] unless $self->has_id;
19              
20 1         6 my $url = sprintf "locations/%s/media/recent", $self->id;
21 1 50       52 API::Instagram->instance->_medias( $url, { @_%2?():@_ } );
22             }
23              
24 2     2   3293 sub _build_name { shift->_data->{name} }
25 1     1   507 sub _build_latitude { shift->_data->{latitude} }
26 1     1   831 sub _build_longitude { shift->_data->{longitude} }
27              
28             sub _build__data {
29 2     2   922 my $self = shift;
30 2 100 50     225 carp "Not available for location with no ID." and return {} unless $self->has_id;
31 1         7 my $url = sprintf "locations/%s", $self->id;
32 1         8 API::Instagram->instance->_get( $url );
33             }
34              
35             1;
36              
37             __END__