lib/mongoid/history/attributes/destroy.rb in mongoid-history-0.6.0 vs lib/mongoid/history/attributes/destroy.rb in mongoid-history-0.6.1
- old
+ new
@@ -2,11 +2,11 @@
module History
module Attributes
class Destroy < ::Mongoid::History::Attributes::Base
def attributes
@attributes = {}
- trackable.attributes.each { |k, v| @attributes[k] = [v, nil] if trackable_class.tracked_field?(k, :destroy) }
+ trackable.attributes.each { |k, v| @attributes[k] = [format_field(k, v), nil] if trackable_class.tracked_field?(k, :destroy) }
insert_embeds_one_changes
insert_embeds_many_changes
@attributes
end
@@ -14,21 +14,19 @@
def insert_embeds_one_changes
trackable_class.tracked_embeds_one
.map { |rel| aliased_fields.key(rel) || rel }
.each do |rel|
- permitted_attrs = trackable_class.tracked_embeds_one_attributes(rel)
obj = trackable.send(rel)
- @attributes[rel] = [obj.attributes.slice(*permitted_attrs), nil] if obj
+ @attributes[rel] = [format_embeds_one_relation(rel, obj.attributes), nil] if obj
end
end
def insert_embeds_many_changes
trackable_class.tracked_embeds_many
.map { |rel| aliased_fields.key(rel) || rel }
.each do |rel|
- permitted_attrs = trackable_class.tracked_embeds_many_attributes(rel)
- @attributes[rel] = [trackable.send(rel).map { |obj| obj.attributes.slice(*permitted_attrs) }, nil]
+ @attributes[rel] = [trackable.send(rel).map { |obj| format_embeds_many_relation(rel, obj.attributes) }, nil]
end
end
end
end
end