annotate vendor/plugins/prepend_engine_views/init.rb @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
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