From d3ffc2e5d194e7e3e1418528217c7022489fa905 Mon Sep 17 00:00:00 2001 From: Jonathan Tapia Date: Sun, 28 Jan 2024 19:06:23 -0600 Subject: [PATCH] Fix zeitwerk issue --- lib/action_view/template/handlers/prawn.rb | 31 ++++++++++++++++++++ lib/prawn_handler.rb | 33 ---------------------- lib/solidus_print_invoice.rb | 2 +- 3 files changed, 32 insertions(+), 34 deletions(-) create mode 100755 lib/action_view/template/handlers/prawn.rb delete mode 100755 lib/prawn_handler.rb diff --git a/lib/action_view/template/handlers/prawn.rb b/lib/action_view/template/handlers/prawn.rb new file mode 100755 index 0000000..db141bf --- /dev/null +++ b/lib/action_view/template/handlers/prawn.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'prawn' + +module ActionView + module Template::Handlers + class Prawn + def self.register! + ::ActionView::Template.register_template_handler :prawn, self + end + + def self.call(template, source = template.source) + %(extend #{::DocumentProxy}; #{source}; pdf.render) + end + + module DocumentProxy + def pdf + @pdf ||= ::Prawn::Document.new(::Spree::PrintInvoice::Config[:prawn_options]) + end + + private + + def method_missing(method, *args, &block) + pdf.respond_to?(method) ? pdf.send(method, *args, &block) : super + end + end + end + end +end + +::ActionView::Template::Handlers::Prawn.register! diff --git a/lib/prawn_handler.rb b/lib/prawn_handler.rb deleted file mode 100755 index 290f4e7..0000000 --- a/lib/prawn_handler.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -require 'prawn' - -module ActionView - module Template - module Handlers - class Prawn - def self.register! - Template.register_template_handler :prawn, self - end - - def self.call(template, source = template.source) - %(extend #{DocumentProxy}; #{source}; pdf.render) - end - - module DocumentProxy - def pdf - @pdf ||= ::Prawn::Document.new(Spree::PrintInvoice::Config[:prawn_options]) - end - - private - - def method_missing(method, *args, &block) - pdf.respond_to?(method) ? pdf.send(method, *args, &block) : super - end - end - end - end - end -end - -ActionView::Template::Handlers::Prawn.register! diff --git a/lib/solidus_print_invoice.rb b/lib/solidus_print_invoice.rb index 1ba86a6..7a0c7fb 100755 --- a/lib/solidus_print_invoice.rb +++ b/lib/solidus_print_invoice.rb @@ -3,7 +3,7 @@ require 'solidus_print_invoice/version' require 'solidus_print_invoice/engine' -require 'prawn_handler' +require 'action_view/template/handlers/prawn' module Spree module PrintInvoice