Adding support to :cast_as => 'Date'.

This commit is contained in:
Tapajós 2009-09-02 23:54:25 -03:00
parent 273a174aae
commit bc6df2f5ca
3 changed files with 10 additions and 1 deletions

View file

@ -53,6 +53,9 @@ module CouchRest
# Auto parse Time objects
self[property.name] = if ((property.init_method == 'new') && target == 'Time')
self[key].is_a?(String) ? Time.parse(self[key].dup) : self[key]
elsif
((property.init_method == 'new') && target == 'Date')
self[key].is_a?(String) ? Date.parse(self[key].dup) : self[key]
else
# Let people use :send as a Time parse arg
klass = ::CouchRest.constantize(target)