Jeffrey Ray Hallock > Storm > Storm::Object

Download:
Storm-0.240.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
View/Report Bugs
Module Version: 0.240   Source  

NAME ^

Storm::Object - Build objects to use with Storm

SYNOPSIS ^

    package Foo;
    use Storm::Object;  # provides Moose sugar

    has 'id' => (
        isa => 'Int',
        traits => [qw( PrimaryKey AutoIncrement )],
    );

    has 'label' => (
        isa => 'Str',
    );

    has 'bar' => (
        isa => 'Bar',
        weak_ref => 1,
    )


    package Bar;

    has 'id' => (
        isa => 'Int',
        traits => [qw( PrimaryKey AutoIncrement )],
    );

    has_many 'foos' => (
        foreign_class => 'Foo',
        match_on => 'bar',
        handles => {
            foos => 'iter',
        }
    );

    has_many 'bazzes' => (
        foreign_class => 'Baz',
        junction_table => 'BazBars',
        local_match => 'bar',
        foreign_match => 'baz',
        handles => {
            bazzes => 'iter',
            add_baz => 'add',
            remove_baz => 'remove',
        }
    );

    package Baz;

    has 'id' => (
        isa => 'Int',
        traits => [qw( PrimaryKey AutoIncrement )],
    );

    has_many 'bars' => (
        foreign_class => 'Foo',
        junction_table => 'BazBars',
        local_match => 'bar',
        foreign_match => 'baz',
        handles => {
            bars => 'iter',
            add_bar => 'add',
            remove_bar => 'remove',
        }
    );

DESCRIPTION ^

Storm::Object is an extension of the Moose object system. The purpose of Storm::Object is to apply the necessary meta-roles Storm needs to introspect your objects and to provide sugar for declaring relationships between Storm enabled objects.

ROLES/META-ROLES ^

Storm::Role::Object

This role is applied to the base class.

Storm::Role::Object::Meta::Attribute

This role is applied to the attribute meta-class.

Storm::Role::Object::Meta::Class

This role is applied to the class meta-class.

SUGAR ^

has_many $name => %options
foreign_class => $class

Set the foreign_class option to the other class in the relationship.

match_on => $attribute_name

Use when defining a one-to-many relationsuhip. This is the name of attribute in the foreign class used to define the relationship.

junction_table => $table

Use when defining a many-to-many relationship. This is the database table used to define the relationships.

local_match => $table

Use when defining a many-to-many relationship. This is the column in the junction_table which is to identify the __PACKAGE__ object in the relationship.

foreign_match => $table

Use when defining a many-to-many relationship. This is the column in the junction_table which is to identify the foreign object in the relationship.

AUTHOR ^

Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com>

COPYRIGHT ^

    Copyright (c) 2010 Jeffrey Ray Hallock. All rights reserved.
    This program is free software; you can redistribute it and/or
    modify it under the same terms as Perl itself.
syntax highlighting: