diff options
author | José Valim <jose.valim@gmail.com> | 2011-07-10 08:35:06 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-07-10 08:36:08 -0300 |
commit | 60076de1d416a68dc52804041f3c8586578acbd9 (patch) | |
tree | ec322b35627147c6d07e979846e11617231a4a22 | |
parent | 3a611cb207ae69ae2053fc165a2f88e5ad1735b3 (diff) | |
download | rails-60076de1d416a68dc52804041f3c8586578acbd9.tar.gz rails-60076de1d416a68dc52804041f3c8586578acbd9.tar.bz2 rails-60076de1d416a68dc52804041f3c8586578acbd9.zip |
Make Rails.groups accept arrays.
-rw-r--r-- | railties/lib/rails.rb | 9 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index df92934457..603ede3d1e 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -4,6 +4,7 @@ require 'pathname' require 'active_support' require 'active_support/core_ext/kernel/reporting' +require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/logger' require 'rails/application' @@ -91,7 +92,7 @@ module Rails # # * The Rails environment; # * The environment variable RAILS_GROUPS; - # * The optional hash given as argument with group dependencies; + # * The optional envs given as argument and the hash with group dependencies; # # == Examples # @@ -101,12 +102,14 @@ module Rails # # => [:default, :development, :assets] for Rails.env == "development" # # => [:default, :production] for Rails.env == "production" # - def groups(hash={}) + def groups(*groups) + hash = groups.extract_options! env = Rails.env - groups = [:default, env] + groups.unshift(:default, env) groups.concat ENV["RAILS_GROUPS"].to_s.split(",") groups.concat hash.map { |k,v| k if v.map(&:to_s).include?(env) } groups.compact! + groups.uniq! groups end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 2547863d12..ff48817f96 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -45,7 +45,7 @@ module ApplicationTests Rails.env = "development" assert_equal [:default, "development"], Rails.groups assert_equal [:default, "development", :assets], Rails.groups(:assets => [:development]) - assert_equal [:default, "development", :assets], Rails.groups(:assets => %w(development)) + assert_equal [:default, "development", :another, :assets], Rails.groups(:another, :assets => %w(development)) Rails.env = "test" assert_equal [:default, "test"], Rails.groups(:assets => [:development]) |