From 60115807e6e5a5ea441fcff1565727ace535793b Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sat, 15 Feb 2014 04:17:18 +0900 Subject: [PATCH] Lazy-load ActionView via ActiveSupport.on_load hook Referencing ActionView::Base constant would kick :action_view load_hooks. This should better not happen for Rails apps when loading bundled awesome_print gem. --- lib/awesome_print.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/awesome_print.rb b/lib/awesome_print.rb index 98d0c74..3c7c928 100755 --- a/lib/awesome_print.rb +++ b/lib/awesome_print.rb @@ -25,7 +25,11 @@ unless defined?(AwesomePrint::Inspector) # # Load remaining extensions. # - require File.dirname(__FILE__) + "/awesome_print/ext/action_view" if defined?(ActionView::Base) + if defined?(ActiveSupport) + ActiveSupport.on_load(:action_view) do + require File.dirname(__FILE__) + "/awesome_print/ext/action_view" + end + end require File.dirname(__FILE__) + "/awesome_print/ext/mongo_mapper" if defined?(MongoMapper) require File.dirname(__FILE__) + "/awesome_print/ext/mongoid" if defined?(Mongoid) require File.dirname(__FILE__) + "/awesome_print/ext/nokogiri" if defined?(Nokogiri)