Messag...Filter(3pm)

πŸ“¦
version 0.117 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

✨ Message::Passing::Role::Filter ✨

okay so bestie, this is a page from the User Contributed Perl Documentation set, and it's all about Message::Passing::Role::Filter πŸ’– a simple abstraction for filtering messages. It's a role, so you don't use it directly β€” you wear it, like a cute little jacket for your own filter class πŸ§₯✨


πŸŽ€ SYNOPSIS πŸŽ€

Like, here's the whole vibe of how you'd use it:

package My::Filter;
use Moo;
use namespace::clean -except => 'meta';

with 'Message::Passing::Role::Filter';

sub filter {
    my ($self, $message) = @_;
    # Do something with $message
    return $message; # Or return undef to halt message!
}

1;

slay. That's it. That's the whole setup. πŸ’…


🌸 DESCRIPTION 🌸

So this thing is both a producer AND a consumer of messages β€” main character energy, fr fr πŸ‘‘ β€” and it's able to filter out messages based upon their contents, or permute the structure of messages. Basically it sits in the middle of your message chain and goes "hmm, do I let this one through, or do I shuffle it around a lil?" πŸ¦‹


πŸ’œ REQUIRED METHODS πŸ’œ

filter

This is the one you have to write, bestie. It gets called to filter the message, and it returns the mangled message β€” yes, "mangled", that's the actual word, iconic πŸ’€

⚠️ IMPORTANT NOTE: if you return undef, then the message is not propagated further up the chain! Which, ngl, is actually super useful β€” that's how you filter out unwanted messages πŸ—‘οΈβœ¨

πŸ¦‹ REQUIRED ATTRIBUTES πŸ¦‹

output_to

This one comes From Message::Passing::Role::Input. You don't define it here, you inherit the requirement, okay? 🫢


⭐ METHODS ⭐

consume

Consumes a message (it's giving hungry, honestly πŸ“) and calls the filter method that you provided, passing in that message.

Then β€” in the case where the filter returns a message β€” it outputs the message to the next step in the chain βž‘οΈπŸ’Œ


πŸ‘€ SEE ALSO πŸ‘€

  • Message::Passing
  • Message::Passing::Manual::Concepts

iykyk, go read those next πŸ’–


πŸ’– SPONSORSHIP πŸ’–

This module exists because of the wonderful people at Suretec Systems Ltd. <http://www.suretecsystems.com/> β€” they sponsored its development for their VoIP division, called SureVoIP <http://www.surevoip.co.uk/>, for use with the SureVoIP API:

<http://www.surevoip.co.uk/support/wiki/api_documentation>

Genuinely so sweet of them, we love a sponsor 🫢🌈


See Message::Passing.


and that's the whole page, bestie!! This one shipped with perl v5.32.1 and the page itself is dated 2021-11-09 πŸŽ€ stay filtered, stay fabulous, mwah πŸ’‹βœ¨