lib/rubber_stamp/revision/publisher.rb in rubber_stamp-0.13.0 vs lib/rubber_stamp/revision/publisher.rb in rubber_stamp-0.15.1
- old
+ new
@@ -15,19 +15,26 @@
def create_or_update_versionable
versionable.present? ? update_versionable : create_versionable
end
def new_attributes
- version_attributes.each_with_object({}) {|v, h| h[v.name] = v.new_value }
+ version_attributes.each_with_object({}) do |version_attribute, hash|
+ new_value = if version_attribute.diff_attributes.any?
+ Revision::DiffAttribute::Rewinder.new(version_attribute, versionable[version_attribute.name]).recompile
+ else
+ version_attribute.new_value
+ end
+ hash[version_attribute.name] = new_value
+ end
end
def create_versionable
version.versionable = version.parent.versionable.public_send(
version.association_name).create(new_attributes)
end
def update_versionable
- versionable.update_attributes(new_attributes)
+ versionable.update_columns(new_attributes)
end
def update_version_children
version_children.each do |child|
update_or_destroy_child(child)
\ No newline at end of file