Class::...de::None(3)

✨ NAME ✨

Okay bestie, this is the Class::...de::None(3) page from User Contributed Perl Documentation, and it's all about Class::DBI::Cascade::None β€” do nothing upon deletion. Literally its whole brand. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

This is a Cascading Delete strategy that will do nothing, leaving orphaned records behind. No cap, it just sits there looking cute while the records become orphans. 😭

Bestie, please clock this: it does nothing on deletion, so orphaned records stay behind. That's the whole point of this strategy.

It is the base class for most ofther Cascade strategies, and so provides several important methods:


πŸ¦‹ CONSTRUCTOR πŸ¦‹

πŸ’– new

my $strategy = Cascade::Class->new($Relationship);

This must be instantiated with a Class::DBI::Relationship object. That part is not optional, bestie β€” it needs the relationship object to do its thing. 🫢


🌸 METHODS 🌸

🧚 foreign_for

my $iterator = $strategy->foreign_for($obj);

This will return all the objects which are foreign to $obj across the relationship. It's a normal Class::DBI search, so you can get the results either as a list or as an iterator. Very choose-your-own-adventure, iykyk. ✨

πŸ”₯ cascade

$strategy->cascade($obj);

Cascade across the related objects to $obj. That's the vibe. πŸ’…


πŸ‘‘ WRITING NEW STRATEGIES πŸ‘‘

Creating a Cascade strategy should be fairly simple, bestie. You usually just need to inherit from here, and then supply a cascade() method that does the required thing with the results from foreign_for().

So, for example, Cascade::Delete is implemented simply as:

package Class::DBI::Cascade::Delete;

use base 'Class::DBI::Cascade::None';

sub cascade {
        my ($self, $obj) = @_;
        $self->foreign_for($obj)->delete_all;
}

Iconic. Ate. Periodt. πŸ“


This little manual page is brought to you by perl v5.42.0, dated 2011-04-08, and the manual name is Class::...de::None(3). Bye bestie, slay your deletions responsibly! πŸ’–πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from