Skip to content

Commit

Permalink
Proper timestamp usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Morgan committed Jun 12, 2009
1 parent 48833e9 commit 64fda32
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions leaves/scorekeeper/lib/datamapper_extensions.rb
@@ -1 +1,20 @@
require 'dm-validations'
require 'dm-timestamps'

DataMapper::Timestamp.class_eval do
private

#HACK Use the current repository, not the default one.
#
# Updates this method to use the currently-scoped repository rather than the
# model's default repository.

def set_timestamps
return unless dirty? || new_record?
TIMESTAMP_PROPERTIES.each do |name,(_type,proc)|
if model.properties(repository.name).has_property?(name)
model.properties(repository.name)[name].set(self, proc.call(self, model.properties(repository.name)[name])) unless attribute_dirty?(name)
end
end
end
end

0 comments on commit 64fda32

Please sign in to comment.