line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Strava::Athlete::Gear; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
1667
|
use v5.010; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
142
|
|
4
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
91
|
|
5
|
4
|
|
|
4
|
|
14
|
use warnings; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
94
|
|
6
|
4
|
|
|
4
|
|
16
|
use Moo; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
16
|
|
7
|
4
|
|
|
4
|
|
842
|
use Method::Signatures; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
22
|
|
8
|
4
|
|
|
4
|
|
1386
|
use Scalar::Util qw(looks_like_number); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
182
|
|
9
|
4
|
|
|
4
|
|
15
|
use Carp qw(croak); |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
142
|
|
10
|
4
|
|
|
4
|
|
18
|
use Scalar::Util::Reftype; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
161
|
|
11
|
4
|
|
|
4
|
|
23
|
use Data::Dumper; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1722
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: An Athlete Gear Object |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION: Generated by DZP::OurPkg:Version |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Validation functions |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $Ref = sub { |
21
|
|
|
|
|
|
|
croak "auth isn't a 'WebService::Strava::Auth' object!" unless reftype( $_[0] )->class eq "WebService::Strava::Auth"; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $Bool = sub { |
25
|
|
|
|
|
|
|
croak "$_[0] must be 0|1" unless $_[0] =~ /^[01]$/; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $Id = sub { |
29
|
|
|
|
|
|
|
croak "$_[0] doesn't appear to be a valid gear id" unless $_[0] =~ /^[bg]\d+/; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Debugging hooks in case things go weird. (Thanks @pjf) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
around BUILDARGS => sub { |
35
|
|
|
|
|
|
|
my $orig = shift; |
36
|
|
|
|
|
|
|
my $class = shift; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
if ($WebService::Strava::DEBUG) { |
39
|
|
|
|
|
|
|
warn "Building task with:\n"; |
40
|
|
|
|
|
|
|
warn Dumper(\@_), "\n"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return $class->$orig(@_); |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Authentication Object |
47
|
|
|
|
|
|
|
has 'auth' => ( is => 'ro', required => 1, isa => $Ref ); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Defaults + Required |
50
|
|
|
|
|
|
|
has 'id' => ( is => 'ro', required => 1, isa => $Id); |
51
|
|
|
|
|
|
|
has '_build' => ( is => 'ro', default => sub { 1 }, isa => $Bool ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has 'primary' => ( is => 'ro', lazy => 1, builder => '_build_gear' ); |
54
|
|
|
|
|
|
|
has 'name' => ( is => 'ro', lazy => 1, builder => '_build_gear' ); |
55
|
|
|
|
|
|
|
has 'distance' => ( is => 'ro', lazy => 1, builder => '_build_gear' ); |
56
|
|
|
|
|
|
|
has 'brand_name' => ( is => 'ro', lazy => 1, builder => '_build_gear' ); |
57
|
|
|
|
|
|
|
has 'model_name' => ( is => 'ro', lazy => 1, builder => '_build_gear' ); |
58
|
|
|
|
|
|
|
has 'description' => ( is => 'ro', lazy => 1, builder => '_build_gear' ); |
59
|
|
|
|
|
|
|
has 'resource_state' => ( is => 'ro', lazy => 1, builder => '_build_gear' ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub BUILD { |
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ($self->{_build}) { |
65
|
0
|
|
|
|
|
|
$self->_build_gear(); |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
4
|
0
|
|
4
|
|
1938
|
method _build_gear() { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $gear = $self->auth->get_api("/gear/$self->{id}"); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
foreach my $key (keys %{ $gear }) { |
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->{$key} = $gear->{$key}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
4
|
0
|
|
4
|
|
2226
|
method retrieve() { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$self->_build_gear(); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__END__ |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=encoding UTF-8 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
WebService::Strava::Athlete::Gear - An Athlete Gear Object |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 VERSION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
version 0.05 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 SYNOPSIS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This class shouldn't be directly instantiated. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is a parent class to 'Gear' objects. Currently Strava |
108
|
|
|
|
|
|
|
has two different Gear types Shoe and Bike. They entirely |
109
|
|
|
|
|
|
|
the same, however a bike can have a frame and model. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 METHODS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 retrieve() |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$gear->retrieve(); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
When a Gear object is lazy loaded, you can call retrieve it by calling |
118
|
|
|
|
|
|
|
this method. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Leon Wright < techman@cpan.org > |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Leon Wright. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
129
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |