The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Interchange6::Schema::Base::Attribute

DESCRIPTION

The Attribute base class is consumed by classes with attribute relationships like Interchange6::Schema::Result::User, Interchange6::Schema::Result::Navigation and Interchange6::Schema::Result::Product.

Assumptions

This module assumes that your using standardized class naming.

example: User in this example is the $base class so UserAttribute, UserAttributeValue class naming would be used. These would also use user_attributes_id and user_attributes_values_id as primary keys. In general follow the example classes listed in description.

SYNOPSIS

    $navigation_object->add_attribute('meta_title','My very seductive title here!');

METHODS

add_attribute

Add attribute.

    $base->add_attribute('hair_color', 'blond');

Where 'hair_color' is Attribute and 'blond' is AttributeValue

update_attribute_value

Update base attribute value

    $base->update_attribute('hair_color', 'brown');

delete_attribute

Delete $base attribute

    $base->delete_attribute('hair_color', 'purple');

search_attributes

Returns attributes resultset for a $base object

    $rs = $base->search_attributes;

You can pass conditions and attributes to the search like for any DBIx::Class::ResultSet, e.g.:

    $rs = $base->search_attributes(
        undef, { order_by => 'priority desc' });

find_attribute_value

Finds the attribute value for the current object or a defined object value. If $object is passed the entire attribute_value object will be returned. $args can accept both scalar and hash inputs.

    $base->find_attribute_value({name => $attr_name, priority => $attr_priority}, {object => 1});

search_attribute_values

Arguments: $cond | undef, \%attrs | undef, \%av_attrs

Where $cond and %attrs are passed to the Attribute search and %av_attrs is passed to the AttributeValue search.

Return Value: Array (or arrayref in scalar context) of attributes and values for for the $base object input.
    my $product = $schema->resultset('Product')->find({ sku = '123' });
    my $av = $product->search_attribute_values(
        undef, { order_by => 'priority' }, { order_by => 'priority' });

find_or_create_attribute

Find or create attribute and attribute_value.

find_base_attribute_value

From a $base->attribute input $base_attribute, $base_attribute_value is returned.