Storm::Object(3)

πŸ“¦
version 0.240 Β· 2 versions
, in fedora 43

πŸ’– 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 the foreign_class option 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 the junction_table that 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 the junction_table that identifies the foreign object in the relationship. the other one. the guest. πŸŽ€
ngl the match_on vs junction_table distinction is the whole plot twist: one-to-many gets match_on, many-to-many gets the junction_table trio. 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 (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