Sha256: 320c46360f2caec2a910f7e4d1ddd62c253b897a0fd08db792be395542877a30

Contents?: true

Size: 684 Bytes

Versions: 3

Compression:

Stored size: 684 Bytes

Contents

require 'prawn'

module ActionView
  module Template::Handlers
    class Prawn 
      def self.register!
        Template.register_template_handler :prawn, self
      end
            
      def self.call(template)
        %(extend #{DocumentProxy}; #{template.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!

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_print_invoice-1.0.2 lib/prawn_handler.rb
solidus_print_invoice-1.0.1 lib/prawn_handler.rb
solidus_print_invoice-1.0.0 lib/prawn_handler.rb