diff --git a/lib/draper.rb b/lib/draper.rb index aef6808..f4fa08e 100644 --- a/lib/draper.rb +++ b/lib/draper.rb @@ -10,7 +10,6 @@ require 'draper/helper_support' require 'draper/view_context' require 'draper/decorated_enumerable_proxy' require 'draper/railtie' if defined?(Rails) -require 'draper/action_controller/base' # Test Support require 'draper/test/rspec_integration' if defined?(RSpec) and RSpec.respond_to?(:configure) diff --git a/lib/draper/action_controller/base.rb b/lib/draper/action_controller/base.rb deleted file mode 100644 index 25d0871..0000000 --- a/lib/draper/action_controller/base.rb +++ /dev/null @@ -1,9 +0,0 @@ -module DraperViewContext - def view_context - super.tap do |context| - Draper::ViewContext.current = context - end - end -end - -ActionController::Base.send(:include, DraperViewContext) diff --git a/lib/draper/system.rb b/lib/draper/system.rb index aff8d8b..ff378cd 100644 --- a/lib/draper/system.rb +++ b/lib/draper/system.rb @@ -2,6 +2,7 @@ module Draper class System def self.setup(component) component.class_eval do + include Draper::ViewContext extend Draper::HelperSupport unless defined?(::ActionMailer) && self.is_a?(::ActionMailer::Base) end end diff --git a/lib/draper/view_context.rb b/lib/draper/view_context.rb index b593dbf..9ad01a6 100644 --- a/lib/draper/view_context.rb +++ b/lib/draper/view_context.rb @@ -7,5 +7,11 @@ module Draper def self.current=(input) Thread.current[:current_view_context] = input end + + def view_context + super.tap do |context| + Draper::ViewContext.current = context + end + end end end