DBIx::...isitor(3pm)

πŸ’– DBIx::...isitor(3pm) β€” bestie edition πŸ’–

okay so first things first, welcome to DBIx::...isitor(3pm), straight out of the User Contributed Perl Documentation section of your friendly neighbourhood man pages. buckle up πŸŽ€


✨ NAME ✨

DBIx::Class::Schema::PopulateMore::Visitor β€” it's the Visitor for the Populate Data. yes that's the whole job description and honestly? iconic. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

    ##Example Usage

that's it. that's the synopsis. no cap. 😭 if you want actual example usage, the manpage says: See Tests for more example usage. go look at the tests, bestie, they're right there 🫢


🌸 DESCRIPTION 🌸

so here's the tea β˜• β€” when you're populating a table, sometimes you gotta inflate values that you literally cannot know in advance. like, imagine you've got a column that's a FK to another column in another table. you don't have the real value yet, you just have a vibe. so the goal here is to make it easy to 'tag' a value as something other than a real value to be inserted into the table. 🏷️

right now there's exactly one substitution to do β€” the FK one mentioned above, that's the whole roster β€” but the possibility of creating other substitution types eventually is real, so this got broken out into its own thing to keep it neat and easy to do so. future-proofing, we love to see it πŸ’…


πŸ’œ ATTRIBUTES πŸ’œ

This class defines the following attributes. (yes, this class. it has attributes. it's that girl.)

πŸŽ€ update_callback

The coderef to be execute should the match condition succeed. (their words, not mine β€” the coderef gets run when the match condition succeeds πŸ’«)

πŸŽ€ match_condition

How we know the value is really something to inflate or perform a substitution on. This get's the namespace of the substitution plugin and it's other data. πŸ”

The default behavior (where there is no substitution namespace) is to do the inflate to resultset. This is the most common usecase. periodt.

πŸŽ€ seen

Used to collect up ref addresses of arrays/hashes we have already seen. it's literally a little memory book of everything we've already laid eyes on πŸ™ˆ


⭐ METHODS ⭐

This module defines the following methods. okay now the good part, the methods, the main characters 🌈

🌟 callback

Given a coderef, sets the current callback and returns self so that we can chain. chaining? obsessed. πŸ”—βœ¨

🌟 visit

A simple visitor that only expects to perform replacements on values. simple. humble. does exactly one thing and does it well. πŸ‘‘

🌟 visit_value

Here is where we make the choice as to if this value needs to be inflated via a plugin. it's giving decision-making. it's giving discernment. 🧚

🌟 match_or_not

We break this out to handle the ugliness surrounding dealing with undef values and also to make it easier on subclassers. undef is a menace and this method is the one brave enough to deal with it πŸ’€


🫢 AUTHOR 🫢

Please see DBIx::Class::Schema::PopulateMore For authorship information. go check that page, they've got the receipts 🧾

also important: the visit method culled from code in Data::Visitor::Lite which is copyright 2011 Daichi Hiroki <hirokidaichi {at} gmail.com> β€” credit where credit is due, always πŸ’–


πŸ’… LICENSE πŸ’…

Please see DBIx::Class::Schema::PopulateMore For licensing terms. same page, same deal, go read it 🌸


and that's the whole page bestie, no notes. go forth and inflate your values responsibly πŸ¦‹

this has been perl v5.36.0, dated 2023-01-22, and it's DBIx::...isitor(3pm) signing off πŸ’œβœ¨ mwah

πŸ“¦ where this page comes from