blib/lib/Keystone/Resolver/DB/Service.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 41 CC 1 SCAR 6.9
CC
1
Cov
0%
table
2.0
fields
2.0
search_fields
2.0
CRAP 2.0
1 # $Id: Service.pm,v 1.20 2008-04-02 13:01:52 mike Exp $
2  
3 package Keystone::Resolver::DB::Service;
4  
5 use strict;
6 use warnings;
7 use Keystone::Resolver::DB::Object;
8  
9 use vars qw(@ISA);
10 @ISA = qw(Keystone::Resolver::DB::Object);
11  
12  
13 # The name of the physical table in which objects of this type are
14 # held.
15 #
16 sub table { "service" }
17  
18 # Unordered list of fields, both physical and virtual, that exist
19 # within records of this type. This function is used extensively
20 # within DB::Object, but there is no good reason for application code
21 # ever to use it directly.
22 #
23 # The LHS is the field name. The RHS for physical fields is
24 # undefined; for virtual fields, it is an array of three, four or five
25 # elements, the first three of which are always the same: the physical
26 # field that provides the link, the class of the kind of object that
27 # it links to, and the field within that class that acts as the link.
28 # When the fourth element is absent, the link is a dependent one to a
29 # single "parent" object; when the fourth element is present, the link
30 # is to a list of associated objects, and the fourth element is the
31 # order in which they should be sorted. Non-dependent-link virtual fields
32 # usually return the name of the parent object, but if a fifth element
33 # is specified it is the name of a parent-object field to return.
34 #
35 # The keys in the hashes returned by the display_fields(),
36 # fulldisplay_fields() and field_map() methods below must be drawn
37 # from those returned by fields(). Those returned by search_fields()
38 # and sort_fields() must, further, be physical fields rather than
39 # virtual.
40 #
41 sub fields { (id => undef,
42 service_type_id => undef,
43 service_type => [ service_type_id => "ServiceType", "id" ],
44 service_type_tag => [ service_type_id => "ServiceType", "id",
45 undef, "tag" ],
46 service_type_plugin => [ service_type_id => "ServiceType", "id",
47 undef, "plugin" ],
48 provider_id => undef,
49 provider => [ provider_id => "Provider", "id" ],
50 tag => undef,
51 name => undef,
52 priority => undef,
53 url_recipe => undef,
54 need_auth => undef,
55 auth_recipe => undef,
56 disabled => undef,
57 ) }
58  
59 # Ordered list of fields for searching. RHS is one of:
60 # t<n> = text field of <n> characters
61 # n<n> = numeric field of <n> characters
62 # b = boolean
63 # s = separator (fieldname is ignored)
64 #
65 sub search_fields { (tag => "t10",
66 name => "t25",
67 priority => "n5",
68 url_recipe => "t25",
69 need_auth => "b",
70 disabled => "b",
71 ) }
72  
73 sub sort_fields { ("priority asc", "name") }
74  
75 # display_fields() and fulldisplay_fields() are ordered list of fields
76 # for display -- the former in single-line record summaries in search
77 # result lists, the latter in single-whole-record displays. LHS is
78 # fieldname. RHS is one of:
79 # t = text
80 # c = code-fragment (text in a fixed-width font)
81 # n = number
82 # b = boolean
83 # ARRAY reference = strings for enumeration
84 # An RHS other than an ARRAY may be preceded by one or more of the
85 # following, in any order:
86 # R: readonly (e.g. "Rt" = readonly text)
87 # X: exclude when creating a new object
88 # L: link through to full record
89 #
90 sub display_fields { (tag => "c",
91 name => "Lt",
92 priority => "n",
93 need_auth => "b",
94 disabled => "b",
95 ) }
96  
97 sub fulldisplay_fields { (service_type => "Rt",
98 provider => "Rt",
99 tag => "Rc",
100 name => "t",
101 priority => "n",
102 url_recipe => "t",
103 need_auth => "b",
104 auth_recipe => "t",
105 disabled => "b",
106 ) }
107  
108 sub uneditable_fields { qw(service_type_tag service_type_plugin) }
109  
110 sub field_map { {
111 url_recipe => "URL recipe",
112 need_auth => "Needs authentication?",
113 auth_recipe => "Authentication recipe",
114 disabled => "Disabled?",
115 } }
116  
117 1;