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


DBIx-Class-Tokenize documentation  | view source Contained in the DBIx-Class-Tokenize distribution.

Index


NAME

Top

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

DESCRIPTION

Top

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

Top

 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

Top

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

Top

J. Shirley, <jshirley at coldhardcode.com>

BUGS

Top

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

Top

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

    perldoc DBIx::Class::Tokenize

You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-Tokenize

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/DBIx-Class-Tokenize

* CPAN Ratings

http://cpanratings.perl.org/d/DBIx-Class-Tokenize

* Search CPAN

http://search.cpan.org/dist/DBIx-Class-Tokenize

ACKNOWLEDGEMENTS

Top

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

COPYRIGHT & LICENSE

Top


DBIx-Class-Tokenize documentation  | view source Contained in the DBIx-Class-Tokenize distribution.