aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/plugin
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-21 22:31:19 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-21 22:31:19 +0000
commit6dd10d85dab9d2623deb3dc4a61106ca9be1d981 (patch)
tree7180753dbf40f804418b983f542d66b3fb3c5e1b /railties/lib/rails/plugin
parent83c17f208933bb895faf9a18194f8a407c194f05 (diff)
downloadrails-6dd10d85dab9d2623deb3dc4a61106ca9be1d981.tar.gz
rails-6dd10d85dab9d2623deb3dc4a61106ca9be1d981.tar.bz2
rails-6dd10d85dab9d2623deb3dc4a61106ca9be1d981.zip
Added the :all option to config.plugins thatll include the rest of the plugins not already explicitly named (closes #9613) [fcheung]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7531 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/rails/plugin')
-rw-r--r--railties/lib/rails/plugin/loader.rb33
1 files changed, 28 insertions, 5 deletions
diff --git a/railties/lib/rails/plugin/loader.rb b/railties/lib/rails/plugin/loader.rb
index d5ad3aa8e3..e935f9b34b 100644
--- a/railties/lib/rails/plugin/loader.rb
+++ b/railties/lib/rails/plugin/loader.rb
@@ -36,8 +36,16 @@ module Rails
def enabled?
!explicit_plugin_loading_order? || registered?
end
-
+
+ def explicitly_enabled?
+ !explicit_plugin_loading_order? || explicitly_registered?
+ end
+
def registered?
+ explicit_plugin_loading_order? && registered_plugins_names_plugin?(name)
+ end
+
+ def explicitly_registered?
explicit_plugin_loading_order? && registered_plugins.include?(name)
end
@@ -54,6 +62,10 @@ module Rails
config.plugins
end
+ def registered_plugins_names_plugin?(plugin_name)
+ registered_plugins.include?(plugin_name) || registered_plugins.include?(:all)
+ end
+
def explicit_plugin_loading_order?
!registered_plugins.nil?
end
@@ -104,20 +116,31 @@ module Rails
# Evaluate in init.rb
def evaluate
- silence_warnings { eval(IO.read(init_path), binding, init_path)} if has_init_file?
+ silence_warnings { eval(IO.read(init_path), binding, init_path) } if has_init_file?
end
def <=>(other_plugin_loader)
if explicit_plugin_loading_order?
- if non_existent_plugin = [self, other_plugin_loader].detect {|plugin| !registered_plugins.include?(plugin.name)}
+ if non_existent_plugin = [self, other_plugin_loader].detect { |plugin| !registered_plugins_names_plugin?(plugin.name) }
plugin_does_not_exist!(non_existent_plugin.name)
end
- registered_plugins.index(name) <=> registered_plugins.index(other_plugin_loader.name)
+ if !explicitly_enabled? && !other_plugin_loader.explicitly_enabled?
+ name <=> other_plugin_loader.name
+ elsif registered_plugins.include?(:all) && (!explicitly_enabled? || !other_plugin_loader.explicitly_enabled?)
+ effective_index = explicitly_enabled? ? registered_plugins.index(name) : registered_plugins.index(:all)
+ other_effective_index = other_plugin_loader.explicitly_enabled? ?
+ registered_plugins.index(other_plugin_loader.name) : registered_plugins.index(:all)
+
+ effective_index <=> other_effective_index
+ else
+ registered_plugins.index(name) <=> registered_plugins.index(other_plugin_loader.name)
+ end
+
else
name <=> other_plugin_loader.name
end
end
end
end
-end
+end \ No newline at end of file