Created
May 23, 2011 11:09
-
-
Save jlecour/986555 to your computer and use it in GitHub Desktop.
Touch plugin for MongoMapper
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
# encoding: UTF-8 | |
module MongoMapper | |
module Plugins | |
module Touch | |
extend ActiveSupport::Concern | |
module InstanceMethods | |
def touch(key = :updated_at) | |
raise "InvalidKey" unless self.key_names.include?(key.to_s) | |
self.set(key => Time.now.utc) | |
true | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But I prefer to store Dates/Times in UTC