
Hook's don't respect STI inheritance model
Reported by Star Trader | January 8th, 2009 @ 07:54 PM
For the following code:
class Person
include DataMapper::Resource
property :id, Serial
property :name, String, :nullable => false
property :type, Discriminator
end
class Man < Person
before :valid? do
name ||= "Anonymous Guy"
end
end
class Woman < Person
before :valid? do
name ||= "Anonymous Gal"
end
end
Given the above, one of the before hooks will not run. It seems that one hook is getting overridden by the other to spite being in different classes
Comments and changes to this ticket
-
Star Trader January 8th, 2009 @ 08:05 PM
Here is a self contained runnable file that demonstrates the problem.
-
Star Trader January 8th, 2009 @ 08:57 PM
- Assigned user set to Carl Lerche
Update:
This is a bug in extlib! The work around is to define all hooks in the root class and if necessary a no-op method on that class.
-
Star Trader January 9th, 2009 @ 02:19 PM
- Tag changed from hooks, sti to extlib, hooks, sti
A patch has been submitted to Extlib (see bug #5).
-
Dan Kubb (dkubb) January 15th, 2009 @ 02:43 AM
- State changed from unconfirmed to resolved
- Assigned user cleared.
This was resolved by:
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »