annotate vendor/plugins/prepend_engine_views/init.rb @ 1469:c77ab1edff6b bug_563

Close obsolete branch bug_563
author Chris Cannam
date Wed, 23 Jan 2013 14:12:47 +0000
parents 513646585e45
children
rev   line source
Chris@0 1 module PrependEngineViews
Chris@0 2 def self.included(base)
Chris@0 3 base.send(:include, InstanceMethods)
Chris@0 4 base.class_eval do
Chris@0 5 alias_method_chain :add_engine_view_paths, :prepend
Chris@0 6 end
Chris@0 7 end
Chris@0 8
Chris@0 9 module InstanceMethods
Chris@0 10 # Patch Rails so engine's views are prepended to the view_path,
Chris@0 11 # thereby letting plugins override application views
Chris@0 12 def add_engine_view_paths_with_prepend
Chris@0 13 paths = ActionView::PathSet.new(engines.collect(&:view_path))
Chris@0 14 ActionController::Base.view_paths.unshift(*paths)
Chris@0 15 ActionMailer::Base.view_paths.unshift(*paths) if configuration.frameworks.include?(:action_mailer)
Chris@0 16 end
Chris@0 17 end
Chris@0 18 end
Chris@0 19
Chris@0 20 Rails::Plugin::Loader.send :include, PrependEngineViews
Chris@0 21