line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::WebService::Tracks::Todo; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7512
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
6
|
use parent 'AnyEvent::WebService::Tracks::Resource'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
53
|
use Carp qw(croak); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
8
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw(looks_like_number); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
88
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->readonly(qw/completed_at created_at id recurring_todo_id updated_at/); |
15
|
|
|
|
|
|
|
__PACKAGE__->accessor(qw/description due notes show_from/); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# here, but not actually accessible: context_id project_id state |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub resource_path { |
20
|
0
|
|
|
0
|
1
|
|
return 'todos'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub xml_root { |
24
|
0
|
|
|
0
|
1
|
|
return 'todo'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub is_complete { |
28
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return $self->{'state'} eq 'completed'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub is_active { |
34
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return $self->{'state'} eq 'active'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub is_project_hidden { |
40
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return $self->{'state'} eq 'project_hidden'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub is_deferred { |
46
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return $self->{'state'} eq 'deferred'; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub complete { |
52
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->{'state'} = 'completed'; |
55
|
0
|
|
|
|
|
|
$self->{'_dirty'}{'state'} = 1; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
if(defined $self->{'show_from'}) { |
58
|
0
|
|
|
|
|
|
undef $self->{'show_from'}; |
59
|
0
|
|
|
|
|
|
$self->{'_dirty'}{'show_from'} = 1; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub activate { |
64
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->{'state'} = 'active'; |
67
|
0
|
|
|
|
|
|
$self->{'_dirty'}{'state'} = 1; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if(defined $self->{'show_from'}) { |
70
|
0
|
|
|
|
|
|
undef $self->{'show_from'}; |
71
|
0
|
|
|
|
|
|
$self->{'_dirty'}{'show_from'} = 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub defer { |
76
|
0
|
|
|
0
|
1
|
|
my ( $self, $amount ) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $show_from; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if(! ref($amount)) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$show_from = DateTime->now->add(days => $amount); |
82
|
|
|
|
|
|
|
} elsif(ref($amount) eq 'DateTime') { |
83
|
0
|
|
|
|
|
|
$show_from = $amount; |
84
|
|
|
|
|
|
|
} elsif(ref($amount) eq 'DateTime::Duration') { |
85
|
0
|
|
|
|
|
|
$show_from = DateTime->now->add_duration($amount); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->{'show_from'} = $show_from; |
89
|
0
|
|
|
|
|
|
$self->{'_dirty'}{'show_from'} = 1; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub context { |
93
|
0
|
|
|
0
|
1
|
|
my ( $self, $cb_or_ctx ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
if(ref($cb_or_ctx) eq 'CODE') { |
96
|
0
|
|
|
|
|
|
my $id = $self->{'context_id'}; |
97
|
0
|
0
|
|
|
|
|
if(defined $id) { |
98
|
0
|
|
|
|
|
|
$self->{'parent'}->fetch_single('contexts', $id, |
99
|
|
|
|
|
|
|
'AnyEvent::WebService::Tracks::Context', $cb_or_ctx); |
100
|
|
|
|
|
|
|
} else { |
101
|
0
|
|
|
|
|
|
$cb_or_ctx->(undef); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} else { |
104
|
0
|
|
|
|
|
|
$self->{'context_id'} = $cb_or_ctx->id; |
105
|
0
|
|
|
|
|
|
$self->{'_dirty'}{'context_id'} = 1; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub project { |
110
|
0
|
|
|
0
|
1
|
|
my ( $self, $cb_or_proj ) = @_; |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if(ref($cb_or_proj) eq 'CODE') { |
113
|
0
|
|
|
|
|
|
my $id = $self->{'project_id'}; |
114
|
0
|
0
|
|
|
|
|
if(defined $id) { |
115
|
0
|
|
|
|
|
|
$self->{'parent'}->fetch_single('projects', $id, |
116
|
|
|
|
|
|
|
'AnyEvent::WebService::Tracks::Project', $cb_or_proj); |
117
|
|
|
|
|
|
|
} else { |
118
|
0
|
|
|
|
|
|
$cb_or_proj->(undef); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} else { |
121
|
0
|
0
|
|
|
|
|
if(defined $cb_or_proj) { |
122
|
0
|
|
|
|
|
|
$self->{'project_id'} = $cb_or_proj->id; |
123
|
|
|
|
|
|
|
} else { |
124
|
0
|
|
|
|
|
|
$self->{'project_id'} = undef; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
|
$self->{'_dirty'}{'project_id'} = 1; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
__END__ |