Sha256: fdabff42c72ebad2aa6685790a3befd2f56978b8ec456cc1f489bd6cfcdefe8b

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 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.env)

    if Rails::VERSION::MAJOR >= 4

      class WickedRailtie < Rails::Railtie
        initializer 'wicked_pdf.register', :after => 'remotipart.controller_helper' do |_app|
          if ActionController::Base.respond_to?(:prepend) &&
             Object.method(:new).respond_to?(:super_method)
            ActionController::Base.send :prepend, PdfHelper
          else
            ActionController::Base.send :include, PdfHelper
          end
          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

3 entries across 3 versions & 1 rubygems

Version Path
wicked_pdf-1.4.0 lib/wicked_pdf/railtie.rb
wicked_pdf-1.3.0 lib/wicked_pdf/railtie.rb
wicked_pdf-1.2.2 lib/wicked_pdf/railtie.rb