Add recipients and documents to hash only when changed
This commit is contained in:
parent
d6b66ff5ce
commit
bec3c8ea85
@ -94,10 +94,13 @@ module Docurest
|
|||||||
emailSubject: emailSubject,
|
emailSubject: emailSubject,
|
||||||
emailBlurb: emailBlurb,
|
emailBlurb: emailBlurb,
|
||||||
emailSettings: emailSettings.to_h,
|
emailSettings: emailSettings.to_h,
|
||||||
documents: documents.map(&:to_h),
|
}.tap do |hash|
|
||||||
recipients: Docurest::Base.hash_by_type(recipients),
|
if documents_changed?
|
||||||
files: files,
|
hash[:documents] = documents.map(&:to_h)
|
||||||
}
|
hash[:files] = files
|
||||||
|
end
|
||||||
|
hash[:recipients] = Docurest::Base.hash_by_type(recipients) if recipients_changed?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -45,8 +45,14 @@ module Docurest
|
|||||||
|
|
||||||
value.send("#{parent_field}=", guid) if parent_field
|
value.send("#{parent_field}=", guid) if parent_field
|
||||||
value.id = values.length + 1 unless value.id
|
value.id = values.length + 1 unless value.id
|
||||||
|
|
||||||
|
instance_variable_set(:"@#{klass}_changed", true)
|
||||||
|
|
||||||
values << value
|
values << value
|
||||||
end
|
end
|
||||||
|
define_method("#{klass}_changed?") do
|
||||||
|
!!instance_variable_get(:"@#{klass}_changed")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user