From 223d31c4f4cafb3dd12cbc7c1dc3b58ef89b61bf Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Thu, 15 Dec 2016 08:02:41 -0500 Subject: [PATCH] include an indicator of which values changed --- app/models/synapse.rb | 1 + app/models/topic.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/synapse.rb b/app/models/synapse.rb index 31e997f4..07a17e54 100644 --- a/app/models/synapse.rb +++ b/app/models/synapse.rb @@ -48,6 +48,7 @@ class Synapse < ApplicationRecord new = self.attributes.select {|k,v| attrs.include?(k) } old = changed_attributes.select {|k,v| attrs.include?(k) } meta = new.merge(old) # we are prioritizing the old values, keeping them + meta['changed'] = changed_attributes.keys.select {|k| attrs.include?(k) } Events::SynapseUpdated.publish!(self, user, meta) end end diff --git a/app/models/topic.rb b/app/models/topic.rb index 4670c286..b2a2b3bc 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -143,6 +143,7 @@ class Topic < ApplicationRecord new = self.attributes.select {|k,v| attrs.include?(k) } old = changed_attributes.select {|k,v| attrs.include?(k) } meta = new.merge(old) # we are prioritizing the old values, keeping them + meta['changed'] = changed_attributes.keys.select {|k| attrs.include?(k) } Events::TopicUpdated.publish!(self, user, meta) end end