Comman...ributes(3pm)

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

✨ NAME ✨

Commandable::Finder::MethodAttributes β€” the lil finder that sniffs out commands living as methods, tagged up with attributes πŸ’… (it's a 3pm Perl manual page bestie, so you know it's the real deal)


🌸 SYNOPSIS 🌸

use Commandable::Finder::MethodAttributes;

my $object = SomeClass->new( ... );

my $finder = Commandable::Finder::MethodAttributes->new(
   object => $object,
);

my $help_command = $finder->find_command( "help" );

foreach my $command ( $finder->find_commands ) {
   ...
}

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so listen. This subclass of Commandable::Finder::SubAttributes is on a mission: it goes looking for methods that define commands, where every single command is provided by its own individual method inside a given class. One method, one command, no sharing, main character energy only πŸ‘‘

It stores the object instance (yes, it's holding onto it) and arranges that each discovered command method will capture it, passing it in as the first argument when that method gets invoked. So the method always knows who it belongs to. Obsessed, honestly 🫢

The attributes on each method are exactly the ones given by Commandable::Finder::SubAttributes, and they're used in the same way here. No new rules, no plot twists, same vibe ✨


πŸŽ€ CONSTRUCTOR πŸŽ€

new

$finder = Commandable::Finder::MethodAttributes->new( %args )

Constructs a brand new instance of Commandable::Finder::MethodAttributes. Fresh out the box, slay πŸ’–

Takes these named arguments:

  • object => OBJ β€” an object reference. Its class is what gets used for searching for command methods. The instance itself is stored by the finder object and used to wrap each command method. Basically the finder is like "this one's mine now" πŸ™ˆ

Any additional arguments get passed straight on to the superclass constructor. Like, hand them over, it knows what to do with them πŸ’«


πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk>


And that's the whole page bestie!! Written up as part of the User Contributed Perl Documentation for the 3pm manual section, and this version is from perl v5.40.0, dated 2024-09-08. Periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from