[jifty-devel] Subclassing models
jesse at bestpractical.com
Sat Jan 5 12:30:57 EST 2008
On Sat, Jan 05, 2008 at 06:43:27AM -0800, Stanislav Sinyagin wrote:
> another thing that I had to figure out myself:
> I need to create several Model classes with similar functionality.
> For example, some classes will have a set of properties stored
> in another model, and would implement set_property and get_property methods.
> Creating these methods in every model class would be too dirty and prone to errors,
> so I subclassed such models from another class where these methods are defined.
> The problem is that I can't put such superclass in MyApp::Model namespace,
> because Jifty expects every class in that namespace to be a valid Model class.
> I created a new namespace MyApp::ModelAddons for such add-ons to the models.
> Probably the core developers would have a better idea of a "canonical" place
> for such add-ons?
[I'm on vacation, so apologies if I don't get to the rest of the
jifty-devel mail for a bit.]
It seems like we've settled on ::Mixin:: (and using mixins, rather than
multiple inheritance, most of the time
Have a look at the Jifty::Plugin::User and Jifty::Plugin::Authentication::Password to see what I'm on about.
Does that make sense?
More information about the jifty-devel