Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Issue mbleigh#69: rails integration lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
sfnelson committed Nov 14, 2019
1 parent 559f374 commit 10c07b3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/princely.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
require 'logger'
require 'pathname'
require 'princely/rails' if defined?(Rails)
require 'princely/railtie' if defined?(Rails)

module Princely
autoload :StdoutLogger, 'princely/stdout_logger'
Expand Down
16 changes: 0 additions & 16 deletions lib/princely/rails.rb

This file was deleted.

27 changes: 27 additions & 0 deletions lib/princely/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'princely/pdf_helper'

module Princely
class Railtie < Rails::Railtie
initializer "princely.helper" do
if Mime::Type.lookup_by_extension(:pdf) != 'application/pdf'
Mime::Type.register 'application/pdf', :pdf
end

if ::Rails::VERSION::MAJOR >= 5
ActiveSupport.on_load(:action_controller) do
prepend Princely::PdfHelper
end
else
ActiveSupport.on_load(:action_controller) do
include Princely::PdfHelper
end
end
if (::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR > 0) ||
(::Rails::VERSION::MAJOR >= 4)
ActiveSupport.on_load(:action_controller) do
include Princely::AssetSupport
end
end
end
end
end

0 comments on commit 10c07b3

Please sign in to comment.