line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Object::Role::Stashable; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
171798
|
use 5.014; |
|
1
|
|
|
|
|
3
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
7
|
1
|
|
|
1
|
|
4
|
use routines; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1382
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '2.01'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# BUILD |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
5
|
0
|
33
|
method BUILD($args) { |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
8
|
|
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
|
|
7
|
return $args; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
around BUILD($args) { |
21
|
|
|
|
|
|
|
$self->$orig($args); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$self->{'$stash'} = {} if !$self->{'$stash'}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return $args; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# METHODS |
29
|
|
|
|
|
|
|
|
30
|
30
|
|
|
30
|
1
|
39395
|
method stash($key, $value) { |
|
30
|
|
|
|
|
48
|
|
|
30
|
|
|
|
|
35
|
|
31
|
30
|
100
|
|
|
|
64
|
return $self->{'$stash'} if !exists $_[0]; |
32
|
|
|
|
|
|
|
|
33
|
29
|
100
|
|
|
|
81
|
return $self->{'$stash'}->{$key} if !exists $_[1]; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
13
|
$self->{'$stash'}->{$key} = $value; |
36
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
24
|
return $value; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=encoding utf8 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Data::Object::Role::Stashable |
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 Moo; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
with 'Data::Object::Role::Stashable'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package main; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $example = Example->new; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This package provides methods for stashing data within the object. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This package implements the following methods: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 stash |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
stash(Maybe[Str] $key, Maybe[Any] $value) : Any |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The stash method is used to fetch and stash named values associated with the |
87
|
|
|
|
|
|
|
object. Calling this method without arguments returns all values. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 4 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item stash example #1 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# given: synopsis |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $result = $example->stash; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
[$result, $example] |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over 4 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item stash example #2 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# given: synopsis |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $result = $example->stash(time => time); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
[$result, $example] |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=over 4 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item stash example #3 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# given: synopsis |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $result = $example->stash('time'); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
[$result, $example] |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Al Newkirk, C |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Copyright (C) 2011-2019, Al Newkirk, et al. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under the terms |
136
|
|
|
|
|
|
|
of the The Apache License, Version 2.0, as elucidated in the L<"license |
137
|
|
|
|
|
|
|
file"|https://github.com/iamalnewkirk/data-object-role-stashable/blob/master/LICENSE>. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 PROJECT |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |