diff options
author | José Valim <jose.valim@gmail.com> | 2011-06-21 08:02:47 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-06-21 11:24:05 -0300 |
commit | a803aec00d3f7cbe09c3ac0233265754ddd0025f (patch) | |
tree | 85217b234844d680513d6de527fa3b822c41d047 /railties/lib/rails.rb | |
parent | 8a889dd45e088014c77f4cd799c9e5ddea0b54c6 (diff) | |
download | rails-a803aec00d3f7cbe09c3ac0233265754ddd0025f.tar.gz rails-a803aec00d3f7cbe09c3ac0233265754ddd0025f.tar.bz2 rails-a803aec00d3f7cbe09c3ac0233265754ddd0025f.zip |
Add Rails.groups to encapsulate available groups for require.
Diffstat (limited to 'railties/lib/rails.rb')
-rw-r--r-- | railties/lib/rails.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index cca0891835..df92934457 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -87,6 +87,29 @@ module Rails RAILS_CACHE end + # Returns all rails groups for loading based on: + # + # * The Rails environment; + # * The environment variable RAILS_GROUPS; + # * The optional hash given as argument with group dependencies; + # + # == Examples + # + # groups :assets => [:development, :test] + # + # # Returns + # # => [:default, :development, :assets] for Rails.env == "development" + # # => [:default, :production] for Rails.env == "production" + # + def groups(hash={}) + env = Rails.env + groups = [: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 + end + def version VERSION::STRING end |