line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
42289
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Mixin::ExtraFields::Hive; |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Mixin::ExtraFields::Hive::VERSION = '0.007'; |
7
|
|
|
|
|
|
|
} |
8
|
1
|
|
|
1
|
|
981
|
use Mixin::ExtraFields 0.002 (); |
|
1
|
|
|
|
|
25334
|
|
|
1
|
|
|
|
|
30
|
|
9
|
1
|
|
|
1
|
|
1192
|
use parent qw(Mixin::ExtraFields); |
|
1
|
|
|
|
|
348
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: infest your objects with hives |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
66
|
use Data::Hive 1.006; |
|
1
|
|
|
|
|
27
|
|
|
1
|
|
|
|
|
24
|
|
14
|
1
|
|
|
1
|
|
1852
|
use Data::Hive::Store::Param 1.001; |
|
1
|
|
|
|
|
888
|
|
|
1
|
|
|
|
|
48
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# I wish this was easier. -- rjbs, 2006-12-09 |
17
|
1
|
|
|
|
|
14
|
use Sub::Exporter -setup => { |
18
|
|
|
|
|
|
|
groups => [ hive => \'gen_fields_group', ], |
19
|
1
|
|
|
1
|
|
6
|
}; |
|
1
|
|
|
|
|
2
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
1
|
395
|
sub default_moniker { 'hive' } |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
1
|
4228
|
sub methods { qw(hive mutate exists empty delete) } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build_mutate_method { |
26
|
2
|
|
|
2
|
|
3
|
my ($self, $arg) = @_; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
|
|
4
|
my $id_method = $arg->{id_method}; |
29
|
2
|
|
|
|
|
2
|
my $driver = $arg->{driver}; |
30
|
2
|
|
|
|
|
7
|
my $driver_set = $self->driver_method_name('set'); |
31
|
2
|
|
|
|
|
14
|
my $driver_get = $self->driver_method_name('get'); |
32
|
2
|
|
|
|
|
13
|
my $driver_all = $self->driver_method_name('get_all'); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return sub { |
35
|
56
|
|
|
56
|
|
19432
|
my $self = shift; |
36
|
56
|
|
|
|
|
132
|
my $id = $self->$$id_method; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
56
|
100
|
|
|
|
309
|
if (@_ == 0) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
40
|
15
|
|
|
|
|
47
|
my %all = $$driver->$driver_all($self, $id); |
41
|
15
|
|
|
|
|
318
|
return keys %all; |
42
|
|
|
|
|
|
|
} elsif (@_ == 1) { |
43
|
28
|
|
|
|
|
54
|
my ($name) = @_; |
44
|
28
|
|
|
|
|
89
|
return $$driver->$driver_get($self, $id, $name); |
45
|
|
|
|
|
|
|
} elsif (@_ == 2) { |
46
|
13
|
|
|
|
|
16
|
my ($name, $value) = @_; |
47
|
13
|
|
|
|
|
51
|
return $$driver->$driver_set($self, $id, $name, $value); |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
0
|
Carp::confess 'too many arguments passed to hive mutator'; |
50
|
|
|
|
|
|
|
} |
51
|
2
|
|
|
|
|
25
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _build_hive_method { |
55
|
2
|
|
|
2
|
|
4
|
my ($self, $arg) = @_; |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
4
|
my $id_method = $arg->{id_method}; |
58
|
2
|
|
|
|
|
3
|
my $moniker = ${ $arg->{moniker} }; |
|
2
|
|
|
|
|
3
|
|
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
5
|
my %store_args = ( |
61
|
|
|
|
|
|
|
method => $self->method_name('mutate', $moniker), |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
5
|
for my $which (qw(exists delete)) { |
65
|
4
|
|
|
|
|
8
|
my $method_name = $self->method_name($which, $moniker); |
66
|
|
|
|
|
|
|
|
67
|
4
|
|
|
27
|
|
19
|
$store_args{ $which } = sub { $_[0]->param_store->$method_name($_[1]) }; |
|
27
|
|
|
|
|
12311
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub { |
71
|
11
|
|
|
11
|
|
3662
|
my ($self) = @_; |
72
|
11
|
|
|
|
|
30
|
my $id = $self->$$id_method; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# We should really get around to caching these in some awesome way. |
75
|
|
|
|
|
|
|
# -- rjbs, 2006-12-09 |
76
|
11
|
|
|
|
|
88
|
Data::Hive->NEW({ |
77
|
|
|
|
|
|
|
store_class => 'Param', |
78
|
|
|
|
|
|
|
store_args => [ $self, \%store_args ], |
79
|
|
|
|
|
|
|
}); |
80
|
|
|
|
|
|
|
} |
81
|
2
|
|
|
|
|
14
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub build_method { |
84
|
10
|
|
|
10
|
1
|
62
|
my ($self, $method, $arg) = @_; |
85
|
|
|
|
|
|
|
|
86
|
10
|
100
|
|
|
|
26
|
return $self->_build_mutate_method($arg) if $method eq 'mutate'; |
87
|
8
|
100
|
|
|
|
23
|
return $self->_build_hive_method($arg) if $method eq 'hive'; |
88
|
|
|
|
|
|
|
|
89
|
6
|
100
|
|
|
|
12
|
$method = 'delete_all' if $method eq 'empty'; |
90
|
|
|
|
|
|
|
|
91
|
6
|
|
|
|
|
21
|
$self->SUPER::build_method($method, $arg); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub driver_method_name { |
95
|
12
|
|
|
12
|
1
|
37
|
my ($self, $method) = @_; |
96
|
12
|
|
|
|
|
35
|
$self->SUPER::method_name($method, 'extra'); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub method_name { |
100
|
16
|
|
|
16
|
1
|
86
|
my ($self, $method, $moniker) = @_; |
101
|
|
|
|
|
|
|
|
102
|
16
|
100
|
|
|
|
47
|
return $moniker if $method eq 'hive'; |
103
|
|
|
|
|
|
|
|
104
|
14
|
|
|
|
|
42
|
return "_$method\_$moniker"; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |