diff --git a/lib/prawn/embedded_files.rb b/lib/prawn/embedded_files.rb index 5e8bd98a1..69cd59d67 100644 --- a/lib/prawn/embedded_files.rb +++ b/lib/prawn/embedded_files.rb @@ -44,14 +44,12 @@ def file(src, options = {}) data = src end - @file_registry ||= {} - file = EmbeddedFile.new(data, mut_opts) - file_obj = @file_registry[file.checksum] + file_obj = file_registry[file.checksum] if file_obj.nil? file_obj = file.build_pdf_object(self) - @file_registry[file.checksum] = file_obj + file_registry[file.checksum] = file_obj end filespec = Filespec.new(file_obj, mut_opts) @@ -63,6 +61,12 @@ def file(src, options = {}) # attach_file(filespec.file_name, filespec_obj) end end + + private + + def file_registry + @file_registry ||= {} + end end end