Skip to content

Commit

Permalink
File registration refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdalilue committed Jul 27, 2021
1 parent 7036083 commit 7e2be54
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/prawn/embedded_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 7e2be54

Please sign in to comment.