NAME

DBIx::Class::Result::ExternalAttribute - The great new DBIx::Class::Result::ExternalAttribute!

VERSION

Version 0.05

SYNOPSIS

use attached model to store attribute.

for example artist result:

package t::app::Main::Result::Artist;
use base qw/DBIx::Class::Core/;
__PACKAGE__->table('artist');
__PACKAGE__->add_columns(
    "id",
    { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
    "name",
    {   data_type     => "varchar",
        default_value => "",
        is_nullable   => 0,
        size          => 255
    });
__PACKAGE__->set_primary_key('id');

__PACKAGE__->load_components(qw/ Result::ExternalAttribute Result::ColumnData /);
__PACKAGE__->init_external_attribute(
    artist_attribute =>
      't::app::Main::Result::ArtistAttribute',
    'artist_id'
);
__PACKAGE__->register_relationships_column_data();

use a artist attribute result:

package t::app::Main::Result::ArtistAttribute;
use base qw/DBIx::Class::Core/;
__PACKAGE__->table('artist_attribute');
__PACKAGE__->add_columns(
    "artist_id",
    { data_type => "integer", is_nullable => 0 },
    "year_old",
    { data_type     => "integer", is_nullable   => 1});
__PACKAGE__->set_primary_key('artist_id');
__PACKAGE__->load_components(qw/ Result::ColumnData /);
__PACKAGE__->belongs_to( artist => "t::app::Main::Result::Artist", 'artist_id');

1;

with this configuration, you can call methods:

$artist->get_column_data => get only columns of artist result

$artist->get_column_data_with_attribute => get columns of Artist and ArtistAttribute result except artist_id

#update with artist attributes
$artist->update({name => "Me", year_old => 15});

#create with artist attributes
my $rh = t::app::Main::Result::Artist->prepare_params_with_attribute({name => "Me", year_old => 15});
$schema->resultset('Artist')->create($rh);

EXPORT

A list of functions that can be exported. You can delete this section if you don't export anything, such as for a purely object-oriented module.

SUBROUTINES/METHODS

rh_klass_attribute_column

accessor to init_external_attrinute HASH configuration

init_external_attribute

init function, declare has one relationships

columns_data_with_attribute

columns_data_with_external_attribute is deprecated, please use get_column_data_with_attribute

get_column_data_with_attribute

extract column_data with attribute column

prepare_params_with_attribute

prepare params for creation with attributes

update

overdefinition of update function

insert

overdefinition of update function

AUTHOR

Nicolas Oudard, <nicolas at oudard.org>

BUGS

Please report any bugs or feature requests to bug-dbix-class-result-externalattribute at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-Result-ExternalAttribute. 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::Result::ExternalAttribute

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Nicolas Oudard.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.