Use Prawn::Document.extensions in favor of custom plug-in loading #31
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative fix to #28 and a replacement of #29. The initial issue was that, when using Prawn plug-ins (e.g. prawn-emoji or prawn-svg), the extension methods would not be available inside of the Rails view. The root cause appears to be how Prawn handles plug-ins. When a plug-in is loaded it adds a module to
Prawn::Document.extensions
. When a new document is created it iterates over the list of extensions and extends the new object with each. The problem is that, whenPrawn::Document
is extended, it copies the list of loaded extensions into the subclass but any plug-ins loaded afterward are not added to the extending class.The fix was to delegate class to
PrawnRails::Document.extensions
toPrawn::Document.extensions
so it's always referencing the correct list.Fixes mogest/prawn-svg#102