Вячеслав Тихановский > ObjectDB-0.990103 > ObjectDB::Relationship::Proxy

Download:
ObjectDB-0.990103.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source  

NAME ^

ObjectDB::Relationship::Proxy - proxy relationship for ObjectDB

SYNOPSIS ^

    package Comment;

    use strict;
    use warnings;

    use base 'ObjectDB';

    __PACKAGE__->schema(
        table        => 'comment',
        columns      => [qw/master_id type content/],
        primary_keys => [qw/master_id type/],

        relationships => {
            master => {
                type      => 'proxy',
                proxy_key => 'type',
            },
            article => {
                type  => 'many to one',
                class => 'Article',
                map   => {master_id => 'id'}
            },
            podcast => {
                type  => 'many to one',
                class => 'Podcast',
                map   => {master_id => 'id'}
            }
        }
    );

    1;

DESCRIPTION ^

This is a proxy relationship. This way you can hold relationship name inside the database. In example above calling $comment->related('master') returns master object depending on $comment->column('type').

ATTRIBUTES ^

proxy_key

Column name used for getting relationship name.

AUTHOR ^

Viacheslav Tykhanovskyi, vti@cpan.org.

COPYRIGHT ^

Copyright (C) 2009, Viacheslav Tykhanovskyi.

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

syntax highlighting: