Algori...:Source(3pm)

✨ Algorithm::Dependency::Source ✨

okay bestie, so this page lives in the User Contributed Perl Documentation section of your man pages, and it's about Algorithm::Dependency::Source, no cap πŸ’–


🌸 NAME 🌸

Algorithm::Dependency::Source β€” the abstract mom of the whole hierarchy-item-source family, implementing a source of hierarchy items πŸ’…


πŸŽ€ VERSION πŸŽ€

version 1.112


πŸ¦‹ DESCRIPTION πŸ¦‹

So Algorithm::Dependency::Source is an abstract parent class β€” a blueprint, a vibe, a template β€” that you use to build sources of the hierarchy data the algorithm is gonna munch on. Think of it as the base fit that all the subclasses build their outfits from πŸ‘‘

If you want a real, working example of an implementation, go peek at Algorithm::Dependency::Source::File, which ships bundled with the main Algorithm::Dependency package. Iconic behavior honestly.


πŸ’– METHODS πŸ’–

🌈 new @arguments

okay so technically you can't directly call the new constructor on Algorithm::Dependency::Source itself β€” but here's the thing: it works exactly the same way in all its subclasses, so it's still the blueprint.

The constructor takes zero or more subclass-specific arguments to define where your source of items is actually hanging out, and it hands you back a shiny new object.

And now for the tea β˜•: even though it may check that the arguments you passed are valid, the source will usually NOT actually load the items from the source. Instead it defers the loading until you actually need the items. Delulu? no, just efficient πŸ’…

Returns a new object on success, or undef on error.

πŸ“ load

The load method is the public method you use to actually load the items from their storage location into the source object. It's the one that does the heavy lifting.

The method gets automatically called, as needed, in most circumstances. So when would you ever call load by hand? Basically only when you're nervous that the source might not load correctly and you wanna vibe check it first 😭

Returns true if the items are loaded successfully, or undef on error.

🌸 item $name

The item method fetches and returns the item object specified by the name argument.

Returns an Algorithm::Dependency::Item object on success, or undef if the named item does not exist in the source. (rip, that item said "not me" 🫢)

⭐ items

The items method returns, as a list of objects, all of the items contained in the source.

And the order? The item objects will be returned in the same order as that in the storage location. Preserving the order, as she should πŸ‘‘

Returns a list of Algorithm::Dependency::Item objects on success, or undef on error.

πŸ’€ missing_dependencies

By default, we are lenient with missing dependencies if the item is never used β€” very chill, very live-and-let-live.

BUT. For systems where having a missing dependency can be very bad, the missing_dependencies method checks all Items to make sure their dependencies exist. Bestie, this is the responsible friend of the group 🧚

If there are any missing dependencies, it returns a reference to an array of their ids. If there are no missing dependencies, it returns 0. Returns undef on error.


πŸ‘‘ EXTENDING πŸ‘‘

So Algorithm::Dependency::Source itself is a fairly thin module, and β€” plot twist β€” it's intended that you will probably need to extend it to be able to extract item data from whatever location you have stored them in. It's giving "base class, do the work yourself" energy πŸ’…

The good news? It's usually a fairly simple two step process.

✨ Overload the new method

Assuming your subclass takes some form or argument on creation, you will need to overload the new method to accept the arguments, validate them, and store them in the source object. Gotta hold onto those args, periodt.

πŸŽ€ Define the method _load_item_list

Leaving our parent's load method to take care of conflict, errors, and whatever, the _load_item_list method is used to simply create a list of Algorithm::Dependency::Item objects from wherever you store the item, and return them as a list.

Once you've done these two things, your subclass should be completed πŸŽ‰ For an example of the code, have a look at the source for the simple subclass Algorithm::Dependency::Source::File.


πŸ”₯ SEE ALSO πŸ”₯

  • Algorithm::Dependency
  • Algorithm::Dependency::Source::File

🫢 SUPPORT 🫢

Got bugs? πŸ‘€ They may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Algorithm-Dependency> (or bug-Algorithm-Dependency@rt.cpan.org <mailto:bug-Algorithm-Dependency@rt.cpan.org>).


πŸ’œ AUTHOR πŸ’œ

Adam Kennedy <adamk@cpan.org>


This software is copyright (c) 2003 by Adam Kennedy.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay that's the whole page bestie, you ate that 🍽️✨ this little doc came to you courtesy of perl v5.40.1, dated 2025-09-18, from the Algorithm::Dependency::Source page β€” and honestly? iconic. stay slaying, and may all your dependencies exist πŸ’–

πŸ“¦ where this page comes from