Michael Boutros
unread,Feb 1, 2008, 12:47:57 PM2/1/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DataMapper
Hello everyone. I was looking over the DataMapper source and first of
all, I have to say awesome job to Sam Smoot and anyone else who
contributed. It really does look great, and it's always readable and I
found my way through the code very easily.
So I started to play around with DM and I noticed that I couldn't
assign multiple properties that all have the same type and options
with one call. Granted, I can do this:
[:property_one, :property_two].each {|p| property p, :string, ...} but
I didn't really like it although I do see how a lot of people would.
So I did what any self-respecting geek would do: I wrote a small
patch. The patch allowed me to do both of the following, with the same
code:
property :name, :string, :length => 30
property :name, :title, :string, :length => 30
The first example is the normal one, and it'd return the new property.
In the second example, an array of the new properties is returned.
However, I went into the IRC channel and some people wanted this:
property [:name, :title], :string, :length => 30
So I went back and worked on it a bit, and now I'm glad to say that
all three of these scenarios work using the _exact_ same code, with no
extra logic required except when the script returns the new properties
(it returns the new property if there's only one, but an array of them
if there's more than one). I wrote a test for it and its all working
dandy, and I'm off to benchmark it right now.
What do you guys think of this? Useful? Pointless? Even if the
community decides not to implement it into the source, I know for sure
I'll be using it in my projects all the time :)