Skip to content

Instantly share code, notes, and snippets.

@flash-gordon
Created June 8, 2015 08:06
Show Gist options
  • Save flash-gordon/87dd3592027bc97ddb83 to your computer and use it in GitHub Desktop.
Save flash-gordon/87dd3592027bc97ddb83 to your computer and use it in GitHub Desktop.
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