On 14.01.2009, at 14:08, heda wrote:
> On another note. Have you any concept objections to dynamic eval
> messages?
>
"Dynamic eval" gave me some creeps initially (I appreciate having
as little magic as possible in the code), but if what you mean is
> I was going to have a look and see at valid? time if the :message is a
> Proc and just execute it within the models scope?
just a way to do
class SubversionOperation < ScmOperation
#
# Validations
#
validates_present :network_connection, :when
=> :committing, :message => proc { |record| "what you think I am, a
Git?!" }
end
then keep in mind message already handles this case:
validates_present :prop, :when => [:update, :create], :message => {
:create => "message for create context",
:update => "message for update context"
}
That is, you need to keep multiple contexts in mind, and thus think
about keeping code simple. I call this feature
"callables expansion" usually. But I am all for it.
I am in the process of rewriting dm-validations spec suite from
scratch, so I'd take on it as soon as I finish with most of it. I am
done with 3 validators
already, and have pretty good set of fixtures to get up to speed with
those left.
MK
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---