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