forked from RISCfuture/autumn
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tim Morgan
committed
Jun 12, 2009
1 parent
48833e9
commit 64fda32
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |