
Storm::Object - Build objects to use with Storm

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',
}
);

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.

This role is applied to the base class.
This role is applied to the attribute meta-class.
This role is applied to the class meta-class.

Set the foreign_class option to the other class in the relationship.
Use when defining a one-to-many relationsuhip. This is the name of attribute in the foreign class used to define the relationship.
Use when defining a many-to-many relationship. This is the database table used to define the relationships.
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.
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.

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

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.