PiFlash::Plugin - plugin extension interface for PiFlash
version 0.4.3
package PiFlash::Plugin::Example; use parent 'PiFlash::Plugin'; # optional init class method - if defined it will be called upon creation of the plugin object sub init { my $self = shift; # perform any object initialization actions here $self->{data} = "value"; # example: subscribe to PiFlash::Hook callbacks PiFlash::Hook::add("fs_mount", sub { ... code to run on callback ... }); PiFlash::Hook::add("post_install", \&function_name); } # get a reference to the plugin's instance variable & data (same as $self in the init function) my $data = PiFlash::Plugin::Example->get_data;
The PiFlash::Plugin module has class methods which manage all the plugins and instance methods which are the base class inherited by each plugin. PiFlash::Hook can be used to receive callback events at various stages of the PiFlash run.
To create a plugin for PiFlash, write a new class under the namespace of PiFlash::Plugin, such as PiFlash::Plugin::Example. All PiFlash plugins must be named under and inherit from PiFlash::Plugin. Otherwise they will not be enabled or accessible.
If the plugin class contains or inherits an init() method, it will be called when the plugin object is created. You don't need to write a new() routine, and shouldn't, because PiFlash::Plugin provides one which must be used by all plugins. That will be called by PiFlash during plugin initialization.
piflash, PiFlash::State, PiFlash::Hook,
Ian Kluft <cpan-dev@iankluft.com>
This software is Copyright (c) 2017-2019 by Ian Kluft.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install PiFlash, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PiFlash
CPAN shell
perl -MCPAN -e shell install PiFlash
For more information on module installation, please visit the detailed CPAN module installation guide.