From 60c244309c67b6b5209c336c43c89083c2d41a0d Mon Sep 17 00:00:00 2001 From: Brad Gessler Date: Tue, 27 Feb 2024 21:07:15 -0800 Subject: [PATCH] Fix render forwarding --- lib/phlex/pdf.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/phlex/pdf.rb b/lib/phlex/pdf.rb index 2992ad0..5001352 100644 --- a/lib/phlex/pdf.rb +++ b/lib/phlex/pdf.rb @@ -10,7 +10,7 @@ class Error < StandardError; end include Prawn::View - def call(document, &block) + def call(document = Prawn::Document.new, &block) @document = document around_template do if block_given? @@ -76,9 +76,10 @@ def render(renderable, &block) end class << self - def document(document = Prawn::Document.new) - new.call(document) - document + def document(...) + Prawn::Document.new.tap do |document| + new(...).call(document) + end end def render(...)