NAME

DBIx::Class::AutoColumn - DBIx::Class extension to provide values for selected columns via hooks

DESCRIPTION

this DBIx::Class component allows you to supply hooks for selected columns in the ResultSource. these hooks will subsequently be used to determine the column's value during INSERT or UPDATE.

SYNOPSIS

package My::Schema::Foo;

__PACKAGE__->load_components('AutoColumn', ..., 'Core');

__PACKAGE__->add_columns(
    id => {
        data_type         => 'integer',
        size              => 4,
        is_nullable       => 0,
        default_value     => undef,
        is_auto_increment => 1,
        is_foreign_key    => 0
    },
    id_octal => {
        data_type         => 'integer',
        size              => 4,
        is_nullable       => 0,
        default_value     => undef,
        is_auto_increment => 0,
        is_foreign_key    => 0,
        column_value_from => \&bar,
    }
);

sub bar
{
    my $row = shift;

    return sprintf '%lo', $row->id;
}