===================================================================
--- engines/lib/engines/plugin.rb (revision 1320)
+++ engines/lib/engines/plugin.rb (working copy)
@@ -30,7 +30,30 @@
#
# Defaults to "assets" (see default_public_directory).
attr_accessor :public_directory
-
+
+ # Plugins may set this to true if they want their views to
+ # take precedence over the views in the main application.
+ # Otherwise, views in plugins that duplicate views in the
+ # application are ignored.
+ #
+ # Defaults to false.
+ attr_accessor :override_views
+
+ # Plugins may set this to false in order to prevent their code from caching
+ # in development mode (in other words, false will force the code to loaded
+ # on each request).
+ #
+ # Defaults to true.
+ attr_reader :load_once
+ def load_once=(new_value)
+ @load_once = new_value
+ if @load_once
+ load_paths.each { |p| Dependencies.load_once_paths << p }
+ else
+ load_paths.each { |p| Dependencies.load_once_paths.delete(p) }
+ end
+ end
+
protected
# The default set of code paths which will be added to $LOAD_PATH
@@ -61,6 +84,8 @@
@code_paths = default_code_paths
@controller_paths = default_controller_paths
@public_directory = default_public_directory
+ @override_views = false
+ @load_once = true
end
# Returns a list of paths this plugin wishes to make available in $LOAD_PATH
@@ -88,7 +113,11 @@
def add_plugin_view_paths
view_path = File.join(directory, 'app', 'views')
if File.exist?(view_path)
- ActionController::Base.view_paths.insert(1, view_path) # push it just underneath the app
+ if @override_views
+ ActionController::Base.prepend_view_path(view_path)
+ else
+ ActionController::Base.view_paths.insert(1, view_path) # push it just underneath the app
+ end
ActionView::TemplateFinder.process_view_paths(view_path)
end
end