Schema/Result/Attribute.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 100% 27 / 27 CC 2 SCAR 4.1
CC
2
Cov
100%
new
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Schema/ResultSet/Tax.pm ↑ Summary Schema/Result/AttributeValue.pm »
1 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Interchange6::Schema::Result::Attribute;
3  
4 =head1 NAME
5  
6 Interchange6::Schema::Result::Attribute
7  
8 =cut
9  
10 2 ▶use Interchange6::Schema::Candy;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 =head1 ACCESSORS
13  
14 =head2 attributes_id
15  
16 Primary key.
17  
18 =cut
19  
20 2 primary_column attributes_id => {
21 data_type => "integer",
22 is_auto_increment => 1,
23 };
24  
25 =head2 name
26  
27 Attribute name, e.g. color or size.
28  
29 Required.
30  
31 =cut
32  
33 2 column name => {
34 data_type => "varchar",
35 size => 255,
36 };
37  
38 =head2 type
39  
40 Attribute type, e.g. variant.
41  
42 Defaults to empty string.
43  
44 =cut
45  
46 2 column type => {
47 data_type => "varchar",
48 default_value => "",
49 size => 255,
50 };
51  
52 =head2 title
53  
54 Displayed title for attribute name, e.g. Color or Size.
55  
56 Defaults to same value as L</name> via L</new> method.
57  
58 =cut
59  
60 2 column title => {
61 data_type => "varchar",
62 size => 255,
63 };
64  
65 =head2 dynamic
66  
67 Boolean flag to designate the attribute as being dynamic.
68  
69 Defaults to false.
70  
71 =cut
72  
73 2 column dynamic => {
74 data_type => "boolean",
75 default_value => 0,
76 };
77  
78 =head2 priority
79  
80 Display order priority.
81  
82 Defaults to 0.
83  
84 =cut
85  
86 2 column priority => {
87 data_type => "integer",
88 default_value => 0,
89 };
90  
91 =head1 UNIQUE CONSTRAINT
92  
93 =head2 attributes_name_type
94  
95 =over 4
96  
97 =item * L</name>
98  
99 =item * L</type>
100  
101 =back
102  
103 =cut
104  
105 2 unique_constraint attributes_name_type => [qw/name type/];
106  
107 =head1 RELATIONS
108  
109 =head2 attribute_values
110  
111 Type: has_many
112  
113 Related object: L<Interchange6::Schema::Result::AttributeValue>
114  
115 =cut
116  
117 2 has_many
118 attribute_values => "Interchange6::Schema::Result::AttributeValue",
119 { "foreign.attributes_id" => "self.attributes_id" },
120 { cascade_copy => 0, cascade_delete => 0 };
121  
122 =head2 product_attributes
123  
124 Type: has_many
125  
126 Related object: L<Interchange6::Schema::Result::ProductAttribute>
127  
128 =cut
129  
130 2 has_many
131 product_attributes => "Interchange6::Schema::Result::ProductAttribute",
132 { "foreign.attributes_id" => "self.attributes_id" },
133 { cascade_copy => 0, cascade_delete => 0 };
134  
135 =head2 navigation_attributes
136  
137 Type: has_many
138  
139 Related object: L<Interchange6::Schema::Result::NavigationAttribute>
140  
141 =cut
142  
143 2 has_many
144 navigation_attributes => "Interchange6::Schema::Result::NavigationAttribute",
145 { "foreign.attributes_id" => "self.attributes_id" },
146 { cascade_copy => 0, cascade_delete => 0 };
147  
148 =head1 METHODS
149  
150 =head2 new
151  
152 Set default value of L</title> to L</name>.
153  
154 =cut
155  
156 sub new {
157 57 ▶ my ( $class, $attrs ) = @_;
Subroutine new: called CC=2 SCAR=6.9
Pod documented
158  
159 57 ▶ $attrs->{title} = $attrs->{name} unless defined $attrs->{title};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $attrs->{"title"} 12 45 57
160  
161 57 my $new = $class->next::method($attrs);
162  
163 57 return $new;
164 }
165  
166 2 1;
« Schema/ResultSet/Tax.pm ↑ Summary Schema/Result/AttributeValue.pm »