Storm::Object(3)
π Storm::Object π
okay bestie, so you know Storm::Object(3)? the manual page from User Contributed Perl Documentation? yeah. that one. sit down, get comfy, we're building objects to use with Storm and honestly? it's giving architecture. it's giving infrastructure. ποΈβ¨
β¨ NAME β¨
Storm::Object β Build objects to use with Storm π«Ά
like. that's the whole vibe. you build objects. Storm uses them. iconic.
πΈ 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',
}
);
like, look at that. three little packages, all of them linked up, all of them thriving. this is the blueprint bestie, this is the whole thing. ππ
π¦ DESCRIPTION π¦
okay so real talk: Storm::Object</p> is an extension of the Moose object system. that's the tea. π΅
and the purpose of it? it's to apply the necessary meta-roles Storm needs so it can introspect your objects (yes, it's looking at your objects, respectfully, it's invited), and to provide sugar for declaring relationships between Storm enabled objects. π¬β¨
so basically: Storm needs to see inside your objects to do its thing, and Storm::Object is the one handing over the keys. no cap. π
π 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. π
three roles, three jobs, all of them carrying the whole thing on their backs. main character energy tbh. π
π SUGAR π
has_many $name => %optionsβ the star of the show, the sugar itself, the moment we've all been waiting for. π and here's everything it takes:foreign_class => $classβ set theforeign_classoption to the other class in the relationship. that's your plus one. π«Άmatch_on => $attribute_nameβ use this one when you're defining a one-to-many relationship. it's the name of the attribute in the foreign class that's used to define the relationship. iykyk. πjunction_table => $tableβ use this when you're defining a many-to-many relationship. it's the database table that defines the relationships. the meeting spot. the group chat. π¬local_match => $tableβ again, for many-to-many. this is the column in thejunction_tablethat identifies the__PACKAGE__object in the relationship. that's you, bestie, that's your column. πforeign_match => $tableβ and this one, also many-to-many. it's the column in thejunction_tablethat identifies the foreign object in the relationship. the other one. the guest. π
ngl thematch_onvsjunction_tabledistinction is the whole plot twist: one-to-many getsmatch_on, many-to-many gets thejunction_tabletrio. don't mix them up or you will be confused. π
π§ AUTHOR π§
Jeffrey Ray Hallock <jeffrey.hallock at gmail dot com> β the architect, the legend, the one who wrote all this down. πβ¨
π 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.
like yes, free software, same terms as Perl itself, we love a permissive queen. π
aaaand that's the whole page bestie!! π go forth and build your objects, link them up, let Storm introspect them, slay. π β¨
this was perl v5.42.0, dated 2025-07-25, and it lives at Storm::Object(3). periodt. ππ¦πΈ
π¦ where this page comes from
- fedora 43: perl-Storm 0.240-34.fc43 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms