
When including DataMapper::Resource twice, it over-rides previous properties
Reported by Postmodern | January 7th, 2009 @ 07:38 PM
In my DataMapper projects I usually have a main Model modules, which includes DataMapper::Resource and sets up various common properties. Additionally, I have other mixins that add properties to my Models. As a safety measure I always include Model into my other mixins.
I discovered that when including multiple mixins, not all the properties showed up in the model. Dan Kubb tracked the problem down to including DataMapper::Resource multiple times. Each time it is included, it will erase previously defined properties, instead of aggregating them together.
Here is a trivial example: http://gist.github.com/44525
Included is a ./bug.rb script which will repeat the bug and print some debugging messages.
The trivial example should print out the PropertySet of the Person model (type, id, address, email). But the 'address' property is not present, even though the HasAddress module is included into Person.
Comments and changes to this ticket
-
Dan Kubb (dkubb) January 8th, 2009 @ 04:25 AM
- State changed from unconfirmed to accepted
-
Justin Smestad February 23rd, 2009 @ 04:26 PM
This is still broken on dm-next. I am getting the same error using his script. /tmp/test-bug > ruby bug.rb [] Included HasAddress into Person [] Included Model into Person [] Included HasEmail into Person [] Included Model into Person [!] Notice how the 'address' property is not present <PropertySet:{#<Property:Person:type>,#<Property:Person:email>,#<Property:Person:id>}>
-
Dan Kubb (dkubb) May 15th, 2009 @ 11:38 PM
- State changed from accepted to resolved
This problem has been fixed in dm-core/next with the following commit:
http://github.com/datamapper/dm-core/commit/10d2a7fda2d3a6d372a0c09...
I have confirmed it works using Postmodern's example scripts, but if this does not work for you please comment and I will re-open this ticket.
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 »