add silent settings for created_at and updated_at, allows for mass assignment with semantics that match rails

This commit is contained in:
Seth Ladd 2009-06-08 16:34:21 -10:00
parent 31180f6bc7
commit ffceaec57d

View file

@ -62,6 +62,9 @@ module CouchRest
property(:updated_at, :read_only => true, :cast_as => 'Time', :auto_validation => false) property(:updated_at, :read_only => true, :cast_as => 'Time', :auto_validation => false)
property(:created_at, :read_only => true, :cast_as => 'Time', :auto_validation => false) property(:created_at, :read_only => true, :cast_as => 'Time', :auto_validation => false)
def created_at=(ignored); end
def updated_at=(ignored); end
save_callback :before do |object| save_callback :before do |object|
object['updated_at'] = Time.now object['updated_at'] = Time.now
object['created_at'] = object['updated_at'] if object.new? object['created_at'] = object['updated_at'] if object.new?