Created
June 8, 2015 08:06
-
-
Save flash-gordon/87dd3592027bc97ddb83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module CommandPlugins | |
module ActiveRecordTimestamps | |
def insert(tuples) | |
now = Time.zone.now | |
tuples_with_timestamps = tuples.map do |tuple| | |
tuple.merge(created_at: now, updated_at: now) | |
end | |
super(tuples_with_timestamps) | |
end | |
def update(tuple) | |
super(tuple.merge(updated_at: Time.zone.now)) | |
end | |
end | |
end | |
ROM.plugins do | |
adapter :sql do | |
register :timestamps, CommandPlugins::ActiveRecordTimestamps, type: :command | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment