line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Valuable; |
2
|
|
|
|
|
|
|
|
3
|
87
|
|
|
87
|
|
1531
|
use 5.018; |
|
87
|
|
|
|
|
322
|
|
4
|
|
|
|
|
|
|
|
5
|
87
|
|
|
87
|
|
474
|
use strict; |
|
87
|
|
|
|
|
193
|
|
|
87
|
|
|
|
|
1756
|
|
6
|
87
|
|
|
87
|
|
407
|
use warnings; |
|
87
|
|
|
|
|
189
|
|
|
87
|
|
|
|
|
2737
|
|
7
|
|
|
|
|
|
|
|
8
|
87
|
|
|
87
|
|
543
|
use Venus::Role 'attr'; |
|
87
|
|
|
|
|
211
|
|
|
87
|
|
|
|
|
641
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ATTRIBUTES |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
attr 'value'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# BUILDERS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub BUILD { |
17
|
8846
|
|
|
8846
|
0
|
18254
|
my ($self, $data) = @_; |
18
|
|
|
|
|
|
|
|
19
|
8846
|
100
|
|
|
|
52302
|
$self->value($self->default) if !exists $data->{value}; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# METHODS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub default { |
25
|
|
|
|
|
|
|
|
26
|
1542
|
|
|
1542
|
1
|
3911
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get { |
30
|
31835
|
|
|
31835
|
1
|
55643
|
my ($self) = @_; |
31
|
|
|
|
|
|
|
|
32
|
31835
|
|
|
|
|
66524
|
return $self->value; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub set { |
36
|
4
|
|
|
4
|
1
|
19
|
my ($self, $value) = @_; |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
20
|
return $self->value($value); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# EXPORTS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub EXPORT { |
44
|
247
|
|
|
247
|
0
|
1134
|
['default', 'get', 'set', 'value'] |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Venus::Role::Valuable - Valuable Role |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 ABSTRACT |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Valuable Role for Perl 5 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package Example; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use Venus::Class; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
with 'Venus::Role::Valuable'; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
package main; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $example = Example->new; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# $example->value; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This package modifies the consuming package and provides a C attribute |
82
|
|
|
|
|
|
|
which defaults to what's returned by the C method, as well as C |
83
|
|
|
|
|
|
|
and C methods for modifying the value. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This package has the following attributes: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 value |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
value(Any) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This attribute is read-write, accepts C<(Any)> values, and is optional. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This package provides the following methods: |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 default |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
default() (Any) |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
The default method returns the default value, i.e. C. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
I> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item default example 1 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
package main; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $example = Example->new; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my $default = $example->default; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# undef |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 get |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
get() (Any) |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The get method gets and returns the value. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
I> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item get example 1 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
package main; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $example = Example->new(value => 'hey, there'); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $get = $example->get; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# "hey, there" |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 set |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
set(Any $value) (Any) |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The set method set the value and returns the value set. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
I> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 4 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item set example 1 |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
package main; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my $example = Example->new(value => 'hey, there'); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $set = $example->set('hi, there'); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# "hi, there" |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=back |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 AUTHORS |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Awncorp, C |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 LICENSE |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
190
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |