DBIx::...ommand(3pm)

✨ DBIx::Class::Schema::PopulateMore::Command ✨

okay bestie, so this whole page is the manual for DBIx::Class::Schema::PopulateMore::Command β€” a Command Class to Populate a Schema, straight out of the User Contributed Perl Documentation section. pull up a chair, we're doing this together πŸ’–


🌸 NAME 🌸

DBIx::Class::Schema::PopulateMore::Command β€” Command Class to Populate a Schema. that's it, that's the name, she's serving exactly what it says on the tin πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

so this is a command pattern class, and her whole job is managing the populating of a DBIx::Class::Schema with information. literally her entire purpose. iconic behavior.

and why did we break it out into its own little class instead of just vibing inside something bigger? three reasons, bestie:

  • the actual job is a bit complex 😭
  • it's likely to grow more complex (she's expanding, she's in her growth era)
  • so that we can more easily identify refactorable and reusable parts πŸ”₯

basically: we separated her out so future-us can find the reusable bits without crying. periodt.


πŸ‘‘ ATTRIBUTES πŸ‘‘

this class defines the following attributes, and we're going through every single one, no skipping:

πŸ’œ schema

This is the Schema we are populating. that's the whole description, she's straightforward and we respect that.

πŸ’œ exception_cb

contains a callback to the exception method supplied by DBIC 🫢

πŸ’œ definitions

This is an arrayref of information used to populate tables in the database.

πŸ’œ 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.

πŸ’œ visitor

We define a visitor so that we can perform the value inflations and or substitutions. This is still a little work in progress, but it's getting neater ✨ (her words, not mine β€” she's still cooking, but she's coming along)

πŸ’œ rs_index

The index of previously inflated resultsets. Basically when we create a new row in the table, we cache the result object so that it can be used as a dependency in creating another.

Eventually will be moved into the constructor for a plugin. (future plans, bestie, we're manifesting it πŸ™ˆ)

πŸ’œ set_rs_index

Set an index value to an inflated result.

πŸ’œ get_rs_index

given an index, returns the related inflated resultset. the classic getter/setter duo, we love to see it πŸ’…

πŸ’œ inflator_loader

Loads each of the available inflators, provider access to the objects.

πŸ’œ inflator_dispatcher

Holds an object that can perform dispatching to the inflators.


πŸŽ€ METHODS πŸŽ€

This module defines the following methods. buckle up, there's a bunch.

🌈 _build_visitor

lazy build for the visitor attribute. lazy but make it functional, we stan 🧚

🌈 _build_inflator_loader

lazy build for the inflator_loader attribute.

🌈 _build_inflator_dispatcher

lazy build for the inflator_dispatcher attribute.

🌈 execute

The command classes main method. Returns a Hash of the created result rows, where each key is the named index and the value is the row object. this is the main character right here, no cap πŸ‘‘

🌈 dispatch_inflator

Dispatch to the correct inflator. short, sweet, does exactly one thing.

🌈 create_fixture({})

Given a hash suitable for a DBIx::Class::Resultset create method, attempt to update or create a row in the named source.

returns the newly created row or throws an exception if there is a failure 😭 so like, handle your errors, bestie.

🌈 merge_fields_values

Given a fields and values, combine to a hash suitable for using in a create_fixture row statement.

🌈 field_value

Correctly create an array from the fields, values variables, skipping those where the value is undefined.

🌈 coerce_to_array

given a value that is either an arrayref or a scalar, put it into array context and return that array. coercion but make it cute πŸ¦‹


πŸ’– AUTHOR πŸ’–

Please see DBIx::Class::Schema::PopulateMore For authorship information.


πŸ’– LICENSE πŸ’–

Please see DBIx::Class::Schema::PopulateMore For licensing terms.


and that's the whole page, bestie!! we did it πŸ’…βœ¨ this was DBIx::...ommand from perl v5.36.0, dated 2023-01-22, and she ate and left no crumbs πŸŽ€πŸ¦‹πŸŒΈ love u, go populate that schema πŸ’–

πŸ“¦ where this page comes from