| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Venus::Role::Stashable; |
|
2
|
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
672
|
use 5.018; |
|
|
34
|
|
|
|
|
126
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
34
|
|
|
34
|
|
226
|
use strict; |
|
|
34
|
|
|
|
|
92
|
|
|
|
34
|
|
|
|
|
747
|
|
|
6
|
34
|
|
|
34
|
|
187
|
use warnings; |
|
|
34
|
|
|
|
|
101
|
|
|
|
34
|
|
|
|
|
1074
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
34
|
|
|
34
|
|
204
|
use Venus::Role 'with'; |
|
|
34
|
|
|
|
|
85
|
|
|
|
34
|
|
|
|
|
342
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# BUILDERS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub BUILD { |
|
13
|
470
|
|
|
470
|
0
|
1163
|
my ($self, $data) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
470
|
100
|
50
|
|
|
8207
|
$self->{'$stash'} = delete $data->{'$stash'} || {} if !$self->{'$stash'}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
470
|
|
|
|
|
1272
|
return $self; |
|
18
|
|
|
|
|
|
|
}; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# METHODS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub stash { |
|
23
|
2652
|
|
|
2652
|
1
|
31294
|
my ($self, $key, $value) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
2652
|
100
|
|
|
|
10623
|
return $self->{'$stash'} if !exists $_[1]; |
|
26
|
|
|
|
|
|
|
|
|
27
|
379
|
100
|
|
|
|
1319
|
return $self->{'$stash'}->{$key} if !exists $_[2]; |
|
28
|
|
|
|
|
|
|
|
|
29
|
242
|
|
|
|
|
837
|
$self->{'$stash'}->{$key} = $value; |
|
30
|
|
|
|
|
|
|
|
|
31
|
242
|
|
|
|
|
793
|
return $value; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# EXPORTS |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub EXPORT { |
|
37
|
64
|
|
|
64
|
0
|
231
|
['stash'] |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Venus::Role::Stashable - Stashable Role |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Stashable Role for Perl 5 |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
package Example; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use Venus::Class; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
with 'Venus::Role::Stashable'; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
attr 'test'; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package main; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $example = Example->new(test => time); |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# $example->stash; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This package modifies the consuming package and provides methods for stashing |
|
77
|
|
|
|
|
|
|
data within the object. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This package provides the following methods: |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 stash |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
stash(Any $key, Any $value) (Any) |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
The stash method is used to fetch and stash named values associated with the |
|
92
|
|
|
|
|
|
|
object. Calling this method without arguments returns all values. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
I> |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over 4 |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item stash example 1 |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
package main; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $example = Example->new(test => time); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $stash = $example->stash; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# {} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=over 4 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item stash example 2 |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
package main; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $example = Example->new(test => time); |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $stash = $example->stash('test', {1..4}); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# { 1 => 2, 3 => 4 } |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item stash example 3 |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
package main; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $example = Example->new(test => time); |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $stash = $example->stash('test'); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# undef |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=back |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHORS |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Awncorp, C |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 LICENSE |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
|
151
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |