line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Stashable; |
2
|
|
|
|
|
|
|
|
3
|
41
|
|
|
41
|
|
824
|
use 5.018; |
|
41
|
|
|
|
|
216
|
|
4
|
|
|
|
|
|
|
|
5
|
41
|
|
|
41
|
|
286
|
use strict; |
|
41
|
|
|
|
|
107
|
|
|
41
|
|
|
|
|
955
|
|
6
|
41
|
|
|
41
|
|
227
|
use warnings; |
|
41
|
|
|
|
|
135
|
|
|
41
|
|
|
|
|
1397
|
|
7
|
|
|
|
|
|
|
|
8
|
41
|
|
|
41
|
|
273
|
use Venus::Role 'with'; |
|
41
|
|
|
|
|
94
|
|
|
41
|
|
|
|
|
454
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# BUILDERS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub BUILD { |
13
|
795
|
|
|
795
|
0
|
2038
|
my ($self, $data) = @_; |
14
|
|
|
|
|
|
|
|
15
|
795
|
100
|
50
|
|
|
10533
|
$self->{'$stash'} = delete $data->{'$stash'} || {} if !$self->{'$stash'}; |
16
|
|
|
|
|
|
|
|
17
|
795
|
|
|
|
|
2083
|
return $self; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub stash { |
23
|
5149
|
|
|
5149
|
1
|
75217
|
my ($self, $key, $value) = @_; |
24
|
|
|
|
|
|
|
|
25
|
5149
|
100
|
|
|
|
19143
|
return $self->{'$stash'} if !exists $_[1]; |
26
|
|
|
|
|
|
|
|
27
|
1320
|
100
|
|
|
|
3174
|
return $self->{'$stash'}->{$key} if !exists $_[2]; |
28
|
|
|
|
|
|
|
|
29
|
1119
|
|
|
|
|
2541
|
$self->{'$stash'}->{$key} = $value; |
30
|
|
|
|
|
|
|
|
31
|
1119
|
|
|
|
|
3145
|
return $value; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# EXPORTS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub EXPORT { |
37
|
76
|
|
|
76
|
0
|
302
|
['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, Awncorp, C. |
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 |