include an indicator of which values changed

This commit is contained in:
Connor Turland 2016-12-15 08:02:41 -05:00
parent 839ff66bcf
commit 223d31c4f4
2 changed files with 2 additions and 0 deletions

View file

@ -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

View file

@ -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