Workflow::Base(3)

πŸ“¦
version 2.09 Β· 2 versions
, in fedora 44

πŸ’– Workflow::Base(3) πŸ’–

User Contributed Perl Documentation ✨ Workflow::Base(3)

okay bestie, welcome to Workflow::Base β€” the little base class that could, the mom friend of your object hierarchy. it's giving "foundation", it's giving "constructor with benefits" 🫢


🌸 NAME 🌸

Workflow::Base β€” a base class with a constructor. that's it. that's the name. short, sweet, iconic.


πŸŽ€ VERSION πŸŽ€

this doc is describing version 2.09 of this package. yes, 2.09. write it down.


πŸ¦‹ SYNOPSIS πŸ¦‹

package My::App::Foo;
use parent qw( Workflow::Base );

that's literally it, babe. inherit and you're in the club πŸ’…


✨ DESCRIPTION ✨

it provides a constructor plus a lil handful of other genuinely useful methods for subclasses. no cap, that's the whole job. it's the base β€” the rest of the family builds on top of it.


πŸ’… METHODS πŸ’…

πŸ‘‘ Class Methods

  • new( @params ) β€” just makes you a brand new object (a blessed hashref, classic) and hands all of @params straight over to the init() method. and init() is a thing subclasses can override so they can set themselves up however they want. Returns: the new object. periodt.

🧚 Object Methods

  • init( @params ) β€” subclasses may implement this to do their initialization. the @params are whatever got passed into new(). nothing needs to be returned β€” no pressure, it's not that kind of method 😌
  • log() β€” returns the logger for the instance, based on the instance class. iykyk.
  • param( [ $name, $value ] ) β€” associate arbitrary parameters with this object. this one has several moods, so let's go one by one:
    • if you give it neither $name nor $value, it returns a hashref of all the parameters set in the object:
my $params = $object->param();
while ( my ( $name, $value ) = each %{ $params } ) {
    print "$name = $params->{ $name }\n";
}
  • if $name is given and it's a hash reference, it assigns all the values of that reference to the object parameters. this is the way to assign multiple parameters at once. heads up though β€” these will overwrite any existing parameter values. it returns a hashref of all parameters set in the object.
$object->param({ foo => 'bar',
                 baz => 'blarney' });
  • if $name is given and it is not a hash reference, it returns the value associated with it, and undef if $name was never set before.
my $value = $object->param( 'foo' );
print "Value of 'foo' is '$value'\n";
  • if both $name and $value are given, it associates $name with $value, overwriting any existing value, and returns the new value.
$object->param( foo => 'blurney' );
  • delete_param( [ $name ] ) β€” deletes parameters from this object. also multi-mood:
    • if $name is given and it's an array reference, then it deletes all those parameters from the object. all the deleted parameters come back as a hash reference together with their values.
my $deleted = $object->delete_param(['foo','baz']);
foreach my $key (keys %{$deleted})
{
  print $key."::=".$deleted->{$key}."\n";
}
  • if $name is given and it is not an array reference, it deletes the parameter and returns the value of the parameter.
my $value = $object->delete_param( 'foo' );
print "Value of 'foo' was '$value'\n";
  • if $name is not defined, or $name does not exist, then undef is returned. so like. don't @ it.
  • clear_params() β€” clears out all parameters associated with this object. scorched earth, bestie πŸ”₯
  • normalize_array( \@array | $item ) β€” if given \@array it returns it dereferenced; if given $item, it returns it in a list. if given neither, it returns an empty list. lowkey the most flexible method in the whole file.

Copyright (c) 2003-2021 Chris Winters. All rights reserved.

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

Please see the LICENSE.


🌈 AUTHORS 🌈

Please see Workflow.


ok so that's the whole page, no skips, no cuts πŸŽ€ go forth and bless some hashrefs.

perl v5.42.0 Β· 2026-01-17 Β· Workflow::Base(3) β€” mwah, that's a wrap, bestie πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from