NAME

DBIx::Class::Tokenize - Automatically tokenize a column on creation

DESCRIPTION

This component simply creates a clean token based on a field on insertion. The simple use case is having a long name that is displayable, like "Catalyst Book" that you want to change to "catalyst_book". Rather than do that by hand every time you create a record, this component does it for you.

SYNOPSIS

package MyApp::Schema::Book;

__PACKAGE__->load_components( qw(Tokenize ... Core) );
__PACKAGE__->add_columns(
    id   => { data_type => 'integer', is_auto_increment => 1 },
    name => { data_type => 'varchar', size => 128, 
       # Update the 'token' field on create
       token_field => 'token' },
    token => { data_type => 'varchar', size => 128, is_nullable => 0 }
);

...

my $row = $schema->resultset('Book')->create({ name => "Catalyst Book" });

print $row->token; # Prints "catalyst_book

METHODS

tokenize

This method is what performs the actual conversion to the tokenized form. It is easy to override so that you can change things around to suit your particular table. Whatever is returned is inserted into the configured token_field.

An example of extending this method would be to traverse a tree in a row that uses DBIx::Class::Tree::AdjacencyList and tokenize the parents as well.

AUTHOR

J. Shirley, <jshirley at coldhardcode.com>

BUGS

Please report any bugs or feature requests to bug-catalyst-controller-rest-dbi c-item at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-Tokenize. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc DBIx::Class::Tokenize

You can also look for information at:

ACKNOWLEDGEMENTS

This is a Cold Hard Code, LLC module - http://www.coldhardcode.com

COPYRIGHT & LICENSE

Copyright 2008 Cold Hard Code, LLC, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.