I'm using M:F:M:Plain as a base class, and am noticing odd inheritance behavior.
I have a base class, Model.pm that does:
use base qw(Maypole::FormBuilder::Model::Plain Class::DBI::mysql);
And the model classes all inherit from Model.pm like so:
use base 'Model';
I've overridden _croak in Model.pm like so:
sub _croak {
my($self, $message) = @_;
Carp::confess($message);
}
In one of my concrete models, we'll call it Model::Concrete, I also override _croak like so:
sub _croak {
my($self, $message) = @_;
… do other stuff with error …
$self->SUPER::_croak($message);
}
My expectation is that when there is a problem in the concrete model, it would call _croak which would hit Model::Concrete->_croak, which would call Model->_croak.. But instead, it's skipping Model->_croak and just calling Model::Concrete->_croak and going straight to Class::DBI->_croak.
So I used Class::ISA to get a list of the inheritance chain of Model::Concrete (it should print it in depth-first, left-to-right order the way inheritance works), and sure enough, I get:
Maypole::FormBuilder::Model::Plain
Maypole::FormBuilder::Model
Maypole::Model::Base
Class::DBI
Class::DBI::__::Base
Class::Data::Inheritable
Class::Accessor
Ima::DBI
Model.pm (My base model class)
Class::DBI::mysql
As you can see, my Model.pm is way at the end of the list, even though it's the direct parent of Model::Concrete.
This only seems to happen when I run out of Maypole. If I write a command line utility to exercise my concrete class, the calling chain seems to work normally. For example, if I call _croak out of an after_create trigger on the concrete class, and write Model::Concrete->create({args}) in a test.pl driver, it works fine. But if I create it through Maypole, my Model.pm trigger is clearly not running.
Is there maybe something about the way Maypole imports models that could be messing with my inheritance hierarchies? Am I just crazy?
thanks,
-ron