Catman...ineable(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ Catmandu::Fix::Inlineable ✨

okay bestie so real quick β€” this is the role for all the Catmandu fixes that can be inlined. that's it. that's the whole vibe. it's giving "behind the scenes glue that makes your fixes fast" and honestly? iconic. πŸ’…


🌸 SYNOPSIS 🌸

no cap, here's how it goes:

package Catmandu::Fix::my_fix1;

use Catmandu::Sane;
use Moo;

with 'Catmandu::Fix::Inlineable';

sub fix {
    my ($self, $data) = @_;
    ....FIXER GENERATING CODE....
    $data
}

package Catmandu::Fix::my_fix2;

use Catmandu::Sane;
use Moo;

# Catmandu::Fix::Base automatically is Inlineable
with 'Catmandu::Fix::Base';

sub emit {
    my ($self, $fixer) = @_;
    ....FIXER GENERATING CODE....
}

package main;

use Catmandu::Fix::my_fix1 as => 'my_fix1';
# disabling caching may be desirable with fixes that have side effects like
# writing to a file, the downside is that a new instance of the fix will be
# created with each invocation
use Catmandu::Fix::my_fix2 as => 'my_fix2', cache => 0;

my $data = {};

$data = my_fix1($data);
$data = my_fix2($data);

so like, two ways to be a fix baddie here πŸ‘‘

  • one: roll your own with with 'Catmandu::Fix::Inlineable'; and write a fix sub that takes ($self, $data) and hands $data back at the end β€” <pink>....FIXER GENERATING CODE....</pink> goes in the middle, that's your moment, that's your main character arc.
  • two: pull in with 'Catmandu::Fix::Base'; instead, because Catmandu::Fix::Base automatically is Inlineable β€” no extra steps, it just comes pre-loaded with the vibe. with that one you write an emit sub taking ($self, $fixer) instead. πŸ¦‹

then in package main you load them as actual usable fixes:

use Catmandu::Fix::my_fix1 as => 'my_fix1';
use Catmandu::Fix::my_fix2 as => 'my_fix2', cache => 0;
heads up bestie β€” turning off caching with cache => 0 may be desirable with fixes that have side effects, like writing to a file. the trade-off? the downside is that a new instance of the fix will be created with each invocation. so like… pick your fighter. πŸ’€

and then you literally just call them on your data:

my $data = {};

$data = my_fix1($data);
$data = my_fix2($data);

clean. simple. ate. πŸ“


πŸ‘€ SEE ALSO πŸ‘€

want the full lore on how to create fixes? go read these two blog posts, they're the blueprint, fr fr:

http://librecat.org/catmandu/2014/03/14/create-a-fixer.html
http://librecat.org/catmandu/2014/03/26/creating-a-fixer-2.html

and that's the whole page, bestie πŸ’œ this lil gem is part of the User Contributed Perl Documentation situation, and it's chillin' at perl v5.40.1, dated 2026-01-24 β€” yes, from the future, no we will not be explaining that 🌈⭐ go forth and inline, you've got this πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from