NAME
DBIx::Class::LookupColumn - A dbic component for building accessors for a lookup table.
VERSION
Version 0.01
SYNOPSIS
__PACKAGE__->load_components( qw/+DBIx::Class::LookupColumn/ );
__PACKAGE__->table("user");
__PACKAGE__->add_columns(
"user_id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"first_name", { data_type => "varchar2", is_nullable => 0, size => 45 },
"last_name", { data_type => "varchar2", is_nullable => 0, size => 45 },
"permission_type_id", { data_type => "integer", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("user_id");
__PACKAGE__->add_lookup( 'permission', 'permission_type_id', 'PermissionType' );
DESCRIPTION
This module generates a few convenient methods (accessors) for accessing data in a lookup table from an associated belongs_to table. It plays with DBIx::Class::LookupColumn::Manager.
What is meant as lookup table is a table containing some terms definition, such as PermissionType (permission_id, name) with such data (1, 'Administrator'; 2, 'User'; 3, 'Reader') associated with a client table (also called target table) such as User, whose metas might look like this : (id, first_name, last_name, permission_id).
EXPORT
add_lookup
METHODS
add_lookup
- Arguments: $relation_name, $foreign_key, $lookup_table, \%options?
- Returned value: no return value.
- Example: __PACKAGE__->add_lookup( 'permission', 'permission_type_id', 'PermissionType', {name_accessor => 'get_the_permission', name_setter => 'set_the_permission, name_checker => 'is_the_permission' } );
GENERATED METHODS
$relation_name
set_$relation_name
is_$relation_name
- Returned value: boolean.
- Description : tell if the value in the lookup table as argument is true or not.
- Example: User->find( 1 )->is_permission( 'Administrator' ).
AUTHOR
Karl Forner <karl.forner@gmail.com>
BUGS
Please report any bugs or feature requests to bug-dbix-class-lookupcolumn at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-LookupColumn. 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::LookupColumn
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBIx-Class-LookupColumn
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENCE AND COPYRIGHT
Copyright 2012 Karl Forner, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the terms as Perl itself.