| 1 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | package Interchange6::Schema::Result::AttributeValue; | ||||||||||
| 3 | |||||||||||
| 4 | =head1 NAME | ||||||||||
| 5 | |||||||||||
| 6 | Interchange6::Schema::Result::AttributeValue | ||||||||||
| 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 attribute_values_id | ||||||||||
| 15 | |||||||||||
| 16 | Primary key. | ||||||||||
| 17 | |||||||||||
| 18 | =cut | ||||||||||
| 19 | |||||||||||
| 20 | 2 | primary_column attribute_values_id => { | |||||||||
| 21 | data_type => "integer", | ||||||||||
| 22 | is_auto_increment => 1, | ||||||||||
| 23 | }; | ||||||||||
| 24 | |||||||||||
| 25 | =head2 attributes_id | ||||||||||
| 26 | |||||||||||
| 27 | Foreign key constraint on | ||||||||||
| 28 | L<Interchange6::Schema::Result::Attribute/attributes_id> | ||||||||||
| 29 | via L</attribute> relationship. | ||||||||||
| 30 | |||||||||||
| 31 | =cut | ||||||||||
| 32 | |||||||||||
| 33 | 2 | column attributes_id => { | |||||||||
| 34 | data_type => "integer", | ||||||||||
| 35 | }; | ||||||||||
| 36 | |||||||||||
| 37 | =head2 value | ||||||||||
| 38 | |||||||||||
| 39 | Value name, e.g. red or white. | ||||||||||
| 40 | |||||||||||
| 41 | Required. | ||||||||||
| 42 | |||||||||||
| 43 | =cut | ||||||||||
| 44 | |||||||||||
| 45 | 2 | column value => { | |||||||||
| 46 | data_type => "varchar", | ||||||||||
| 47 | size => 255, | ||||||||||
| 48 | }; | ||||||||||
| 49 | |||||||||||
| 50 | =head2 title | ||||||||||
| 51 | |||||||||||
| 52 | Displayed title for attribute value, e.g. Red or White. | ||||||||||
| 53 | |||||||||||
| 54 | Defaults to same value as L</value> via L</new> method. | ||||||||||
| 55 | |||||||||||
| 56 | =cut | ||||||||||
| 57 | |||||||||||
| 58 | 2 | column title => { | |||||||||
| 59 | data_type => "varchar", | ||||||||||
| 60 | size => 255, | ||||||||||
| 61 | }; | ||||||||||
| 62 | |||||||||||
| 63 | =head2 priority | ||||||||||
| 64 | |||||||||||
| 65 | Display order priority. | ||||||||||
| 66 | |||||||||||
| 67 | Defaults to 0. | ||||||||||
| 68 | |||||||||||
| 69 | =cut | ||||||||||
| 70 | |||||||||||
| 71 | 2 | column priority => { | |||||||||
| 72 | data_type => "integer", | ||||||||||
| 73 | default_value => 0, | ||||||||||
| 74 | }; | ||||||||||
| 75 | |||||||||||
| 76 | =head1 UNIQUE CONSTRAINT | ||||||||||
| 77 | |||||||||||
| 78 | =head2 attribute_values_attributes_id_value | ||||||||||
| 79 | |||||||||||
| 80 | =over 4 | ||||||||||
| 81 | |||||||||||
| 82 | =item * L</attributes_id> | ||||||||||
| 83 | |||||||||||
| 84 | =item * L</value> | ||||||||||
| 85 | |||||||||||
| 86 | =back | ||||||||||
| 87 | |||||||||||
| 88 | =cut | ||||||||||
| 89 | |||||||||||
| 90 | 2 | unique_constraint attribute_values_attributes_id_value => | |||||||||
| 91 | [qw/attributes_id value/]; | ||||||||||
| 92 | |||||||||||
| 93 | =head1 RELATIONS | ||||||||||
| 94 | |||||||||||
| 95 | =head2 attribute | ||||||||||
| 96 | |||||||||||
| 97 | Type: belongs_to | ||||||||||
| 98 | |||||||||||
| 99 | Related object: L<Interchange6::Schema::Result::Attribute> | ||||||||||
| 100 | |||||||||||
| 101 | =cut | ||||||||||
| 102 | |||||||||||
| 103 | 2 | belongs_to | |||||||||
| 104 | attribute => "Interchange6::Schema::Result::Attribute", | ||||||||||
| 105 | { attributes_id => "attributes_id" }, | ||||||||||
| 106 | { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }; | ||||||||||
| 107 | |||||||||||
| 108 | =head2 product_attribute_values | ||||||||||
| 109 | |||||||||||
| 110 | Type: has_many | ||||||||||
| 111 | |||||||||||
| 112 | Related object: L<Interchange6::Schema::Result::ProductAttributeValue> | ||||||||||
| 113 | |||||||||||
| 114 | =cut | ||||||||||
| 115 | |||||||||||
| 116 | 2 | has_many | |||||||||
| 117 | product_attribute_values => | ||||||||||
| 118 | "Interchange6::Schema::Result::ProductAttributeValue", | ||||||||||
| 119 | { "foreign.attribute_values_id" => "self.attribute_values_id" }, | ||||||||||
| 120 | { cascade_copy => 0, cascade_delete => 0 }; | ||||||||||
| 121 | |||||||||||
| 122 | =head2 user_attribute_values | ||||||||||
| 123 | |||||||||||
| 124 | Type: has_many | ||||||||||
| 125 | |||||||||||
| 126 | Related object: L<Interchange6::Schema::Result::UserAttributeValue> | ||||||||||
| 127 | |||||||||||
| 128 | =cut | ||||||||||
| 129 | |||||||||||
| 130 | 2 | has_many | |||||||||
| 131 | user_attribute_values => "Interchange6::Schema::Result::UserAttributeValue", | ||||||||||
| 132 | { "foreign.attribute_values_id" => "self.attribute_values_id" }, | ||||||||||
| 133 | { cascade_copy => 0, cascade_delete => 0 }; | ||||||||||
| 134 | |||||||||||
| 135 | =head2 navigation_attribute_values | ||||||||||
| 136 | |||||||||||
| 137 | Type: has_many | ||||||||||
| 138 | |||||||||||
| 139 | Related object: L<Interchange6::Schema::Result::NavigationAttributeValue> | ||||||||||
| 140 | |||||||||||
| 141 | =cut | ||||||||||
| 142 | |||||||||||
| 143 | 2 | has_many | |||||||||
| 144 | navigation_attribute_values => | ||||||||||
| 145 | "Interchange6::Schema::Result::NavigationAttributeValue", | ||||||||||
| 146 | { "foreign.attribute_values_id" => "self.attribute_values_id" }, | ||||||||||
| 147 | { cascade_copy => 0, cascade_delete => 0 }; | ||||||||||
| 148 | |||||||||||
| 149 | =head1 METHODS | ||||||||||
| 150 | |||||||||||
| 151 | =head2 new | ||||||||||
| 152 | |||||||||||
| 153 | Set default value of L</title> to L</name>. | ||||||||||
| 154 | |||||||||||
| 155 | =cut | ||||||||||
| 156 | |||||||||||
| 157 | sub new { | ||||||||||
| 158 | 176 | ▶ | my ( $class, $attrs ) = @_; | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 159 | |||||||||||
| 160 | 176 | ▶ | $attrs->{title} = $attrs->{value} unless defined $attrs->{title}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 161 | |||||||||||
| 162 | 176 | my $new = $class->next::method($attrs); | |||||||||
| 163 | |||||||||||
| 164 | 176 | return $new; | |||||||||
| 165 | } | ||||||||||
| 166 | |||||||||||
| 167 | 2 | 1; | |||||||||