| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OpusVL::Preferences; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
105429
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
54
|
|
|
4
|
2
|
|
|
2
|
|
9
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
62
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Generic DBIC preferences module |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.27'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1; # End of OpusVL::Preferences |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__END__ |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=pod |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=encoding UTF-8 |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
OpusVL::Preferences - Generic DBIC preferences module |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 VERSION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
version 0.27 |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This is a really simple module to pull into result classes so you can attach |
|
31
|
|
|
|
|
|
|
preferences, rather than have to continually extend the schema definition where |
|
32
|
|
|
|
|
|
|
its probably not appropriate. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Say you had an Employees class, and wanted to define the following preferences |
|
35
|
|
|
|
|
|
|
for a customer: |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item grows_plants |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item has_untidy_desk |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item likes_noodles |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=back |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
You would set up your Result class as follows: |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
package Result::Employee; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
use strict; |
|
52
|
|
|
|
|
|
|
use Moose; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
extends 'DBIx::Class::Core'; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
with 'OpusVL::Preferences::RolesFor::Result::PrfOwner'; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__PACKAGE__->prf_owner_init; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
... |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
And the ResultSet class would be: |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package ResultSet::Employee; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use strict; |
|
67
|
|
|
|
|
|
|
use Moose; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
extends 'DBIx::Class::ResultSet'; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
with 'OpusVL::Preferences::RolesFor::ResultSet::PrfOwner'; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
... |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This would initialise the class with 3 preferences, set to the appropriate |
|
76
|
|
|
|
|
|
|
defaults. Within the Employee class, the following methods are exposed to |
|
77
|
|
|
|
|
|
|
manage the preferences: |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 Result Class Methods |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head3 prf_get |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Get the current value of the preference (either the default or local copy as |
|
84
|
|
|
|
|
|
|
appropriate). |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$p = $employee->prf_get ('grows_plants'); # $p == 1 |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head3 prf_set |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Overides the default preference value for the employee in question: |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$employee = prf_set (grows_plants => 0); |
|
93
|
|
|
|
|
|
|
$p = $employee->prf_get ('grows_plants'); # $p == 0 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head3 prf_reset |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Deletes any local overrides and uses the default |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$employee->prf_reset ('grows_plants'); |
|
100
|
|
|
|
|
|
|
$p = $employee->prf_get ('grows_plants'); # $p == 1 |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head3 prf_preferences |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns a resultset containing PrfPreference classes. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 ResultSet Methods |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head3 prf_defaults |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns a resultset of the default preferences setup for this resultset. Add |
|
111
|
|
|
|
|
|
|
more results to this object to add more defaults. For example, the following |
|
112
|
|
|
|
|
|
|
might be in the initdb routine: |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub initdb |
|
115
|
|
|
|
|
|
|
{ |
|
116
|
|
|
|
|
|
|
my $self = shift; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$self->prf_defaults->populate |
|
119
|
|
|
|
|
|
|
([ |
|
120
|
|
|
|
|
|
|
{ name => 'grown_plants' => default_value => '1' }, |
|
121
|
|
|
|
|
|
|
{ name => 'has_untidy_desk' => default_value => '1' }, |
|
122
|
|
|
|
|
|
|
{ name => 'likes_noodles' => default_value => '1' }, |
|
123
|
|
|
|
|
|
|
]); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head3 prf_search |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
To be completed. Will allow an Employee resultset to be return using |
|
129
|
|
|
|
|
|
|
preferences as a search parameter. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 BUGS |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
None. Past, present and future. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SUPPORT |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
perldoc OpusVL::Preferences |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
If you require assistance, support, or further development of this software, please contact OpusVL using the details below: |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=over 4 |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Telephone: +44 (0)1788 298 410 |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Email: community@opusvl.com |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Web: L<http://opusvl.com> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 AUTHOR |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
OpusVL - www.opusvl.com |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This software is copyright (c) 2011 by OpusVL - www.opusvl.com. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
170
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |