Sha256: e759af4b9fe387f07bb47a10fab5d51620e39699b6505cfd645333524fd67e7c

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

require 'wicked_pdf/pdf_helper'
require 'wicked_pdf/wicked_pdf_helper'
require 'wicked_pdf/wicked_pdf_helper/assets'

class WickedPdf
  if defined?(Rails)

    if Rails::VERSION::MAJOR >= 5

      class WickedRailtie < Rails::Railtie
        initializer 'wicked_pdf.register' do |_app|
          ActionController::Base.send :prepend, PdfHelper
          ActionView::Base.send :include, WickedPdfHelper::Assets
        end
      end

    elsif Rails::VERSION::MAJOR == 4

      class WickedRailtie < Rails::Railtie
        initializer 'wicked_pdf.register' do |_app|
          ActionController::Base.send :include, PdfHelper
          ActionView::Base.send :include, WickedPdfHelper::Assets
        end
      end

    elsif Rails::VERSION::MAJOR == 3

      class WickedRailtie < Rails::Railtie
        initializer 'wicked_pdf.register' do |_app|
          ActionController::Base.send :include, PdfHelper
          if Rails::VERSION::MINOR > 0 && Rails.configuration.assets.enabled
            ActionView::Base.send :include, WickedPdfHelper::Assets
          else
            ActionView::Base.send :include, WickedPdfHelper
          end
        end
      end

    elsif Rails::VERSION::MAJOR == 2

      unless ActionController::Base.instance_methods.include? 'render_with_wicked_pdf'
        ActionController::Base.send :include, PdfHelper
      end
      unless ActionView::Base.instance_methods.include? 'wicked_pdf_stylesheet_link_tag'
        ActionView::Base.send :include, WickedPdfHelper
      end

    end

    if Mime::Type.lookup_by_extension(:pdf).nil?
      Mime::Type.register('application/pdf', :pdf)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wicked_pdf-1.1.0 lib/wicked_pdf/railtie.rb