Plugin(3pm)

πŸ“¦
version 0.03 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Class::DBI::Plugin πŸ’–

okay bestie, listen up β€” this is Plugin(3pm), a User Contributed Perl Documentation page, and it's genuinely so cute. it's the abstract base class for Class::DBI plugins. slay.


✨ NAME ✨

Class::DBI::Plugin β€” the abstract base class for Class::DBI plugins. that's the whole vibe. periodt.


🌸 SYNOPSIS 🌸

okay so here's what it actually looks like when you use it, copy-paste this energy:

use base 'Class::DBI::Plugin';

sub init {
  my $class = shift;
  $class->set_sql( statement_name => ... );
  $class->add_trigger( ... );
  $class->columns( TEMP => ... );
}

sub method_name : Plugged {
  my $class = shift;
  $class->sql_statement_name( ... );
}

sub this_method_is_not_exported {}

see how method_name has that : Plugged attribute? yeah. that's the whole trick. iykyk. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so Class::DBI::Plugin is an abstract base class for Class::DBI plugins, and its whole purpose is literally just to make writing plugins easier. like, plugin writers should get to focus on the actual functionality their module provides instead of dealing with symbol table hackery β€” because ngl, symbol table hackery when you're writing a plugin module is so not the moment. πŸ™ˆ

only three things you gotta remember, bestie. three. that's it:

  1. every method that's meant to be exported gets the "Plugged" attribute. every other method? not exported to the plugged-in class. simple as that.
  2. method calls that need to go to the plugged-in class live inside the init() method. examples of these include set_sql(), add_trigger(), and so on. so many and so on.
  3. the class parameter for the init() method and for the "Plugged" methods is the plugged-in class, not the plugin class. this one is important, don't get it twisted. πŸ‘‘

πŸ’€ CAVEATS πŸ’€

okay so real talk, and this is the part where we hold hands 🫢:

so far this module only "sees" methods in the plugin module itself. if there's a class sitting between the base class and the plugin class in the inheritance hierarchy, methods of that class will not be found. in other words: inherited methods will not be found. if requested, the author will implement this behaviour.

so like… it just doesn't see them. that's the tea. 😭

πŸŽ€ TODO πŸŽ€

it might be useful for plugin users to be able to choose only the plugin methods they're actually interested in, if there's more than one of them. this is not implemented yet. so don't come for it. πŸ“


🌈 SEE ALSO 🌈

  • Class::DBI

πŸ’œ AUTHOR πŸ’œ

Jean-Christophe Zeus, <mail@jczeus.com> β€” with some help from Simon Cozens. many thanks to Mark Addison for the idea with the init() method, and many thanks to Steven Quinney for the idea with the subroutine attributes. icons supporting icons, we love to see it. πŸ‘‘


Copyright (C) 2004 by Jean-Christophe Zeus

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


and that's the whole page bestie!! ✨ this is Plugin(3pm) from perl v5.32.0, dated 2021-01-06 β€” mwah, iconic, no notes, go write a plugin πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from