Skip to content
Browse files

Make Rails.groups accept arrays.

  • Loading branch information...
1 parent e249dd9 commit 4c76991120b6cddb8590ad9ec9ad85425887b22a @josevalim josevalim committed Jul 10, 2011
Showing with 7 additions and 4 deletions.
  1. +6 −3 railties/lib/rails.rb
  2. +1 −1 railties/test/application/configuration_test.rb
View
9 railties/lib/rails.rb
@@ -4,6 +4,7 @@
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 @@ def cache
#
# * 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 @@ def cache
# # => [: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
View
2 railties/test/application/configuration_test.rb
@@ -45,7 +45,7 @@ def teardown
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])

0 comments on commit 4c76991

Please sign in to comment.
Something went wrong with that request. Please try again.