[Catalyst] How do you extend a model class from a plugin

ben.norman at qmunity.net ben.norman at qmunity.net
Tue Nov 29 03:01:52 CET 2005


I have a couple of functions that I want to be available to an Application if my
Plugin is invoked. The functions should be available as class methods on model
classes.
Currently I just have the Model Class using a class as a base to get the
functionality but if I want to deliver it to the community to use then I would
like it to be in the Plugin itself.
I feel a bit dirty putting model functions in a plugin class but they are
married. If the plugin is not used then the functions don’t make sense.

package MyApp;
use Catalyst qw/ MyPlugin /;
1;
package MyApp::Model::DB;
use base MyGenericModel;
1;
package Catalyst::Plugin::MyPlugin;
1;

To deliver the functionality all as one package I would like to make the
invocation of MyPlugin extend MyApp::Model::DB. Can you extend the features of
a Model class in a Plugin?

If I can extend the Model from the Plugin then the packages would look like
this.

package MyApp;
use Catalyst qw/ MyPlugin /;
1;
Package Catalyst::Plugin::MyPlugin;
# do stuff to add a function as a class function to the c$->model('DB');
1;

Thanks
ben


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Catalyst mailing list