
DataMapper::Base::embed should support options
Reported by Sam Smoot | November 13th, 2007 @ 12:03 AM
Example:
class Person < DataMapper::Base
property :name, :string
property :age, :integer
property :occupation, :string
property :type, :class
property :notes, :text, :lazy => true
embed :address, :prefix => 'address_', :lazy => true do
property :street, :string
property :city, :string
property :state, :string, :size => 2
property :zip_code, :string, :size => 10
end
end
:lazy would lazy-load all the embedded values at the same time (the lazy_load! method already supports loading multiple attributes).
The :prefix option would define a column-prefix. So instead of mapping :street to a 'street' column, it would map to an 'address_street' column. ":prefix => true" might also be a short-cut to using "#{embedded_name}_" as the prefix (so in this case, it would be short for :prefix => "address_").
Also, embedded values should generate convenience methods that delegate to the EV's properties/accessors. So embed :address { property :street } would also create a Person.first.address_street so it can be easily used in #update_attributes= or for tag#name building. But Person#address_Street would delegate to Person#address#street in case you'd overridden it with a custom accessor.
Comments and changes to this ticket
-
Nick Plante November 9th, 2007 @ 09:20 PM
- Milestone cleared.
-
Nick Plante November 12th, 2007 @ 10:10 AM
- Assigned user set to Nick Plante
-
Nick Plante November 12th, 2007 @ 03:32 PM
r500 includes :prefix option support
TODO: :lazy loading for embedded values
-
Nick Plante November 15th, 2007 @ 03:09 PM
- State changed from open to resolved
in r507, might want to add some extra specs to better test the lazy loading capabilities in general though (not just specific to embed, that is)
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 »