diff options
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/configuration.rb | 48 | ||||
-rw-r--r-- | railties/lib/rails/rack/metal.rb | 8 |
2 files changed, 54 insertions, 2 deletions
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 1a2f217d20..fe3cb67d3a 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -249,5 +249,51 @@ module Rails def reload_plugins? @reload_plugins end + + # Holds generators configuration: + # + # config.generators do |g| + # g.orm :datamapper, :migration => true + # g.template_engine :haml + # g.test_framework :rspec + # end + # + # If you want to disable color in console, do: + # + # config.generators.colorize_logging = false + # + def generators + @generators ||= Generators.new + if block_given? + yield @generators + else + @generators + end + end + + class Generators #:nodoc: + attr_accessor :aliases, :options, :colorize_logging + + def initialize + @aliases = Hash.new { |h,k| h[k] = {} } + @options = Hash.new { |h,k| h[k] = {} } + @colorize_logging = true + end + + def method_missing(method, *args) + method = method.to_s.sub(/=$/, '').to_sym + namespace = args.first.is_a?(Symbol) ? args.shift : nil + configuration = args.first.is_a?(Hash) ? args.shift : nil + + @options[:rails][method] = namespace if namespace + namespace ||= method + + if configuration + aliases = configuration.delete(:aliases) + @aliases[namespace].merge!(aliases) if aliases + @options[namespace].merge!(configuration) + end + end + end end -end
\ No newline at end of file +end diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb index b031be29af..6c0732f732 100644 --- a/railties/lib/rails/rack/metal.rb +++ b/railties/lib/rails/rack/metal.rb @@ -11,6 +11,9 @@ module Rails cattr_accessor :metal_paths self.metal_paths = ["#{Rails.root}/app/metal"] cattr_accessor :requested_metals + + cattr_accessor :pass_through_on + self.pass_through_on = 404 def self.metals matcher = /#{Regexp.escape('/app/metal/')}(.*)\.rb\Z/ @@ -36,6 +39,9 @@ module Rails def initialize(app) @app = app + @pass_through_on = {} + [*self.class.pass_through_on].each { |status| @pass_through_on[status] = true } + @metals = ActiveSupport::OrderedHash.new self.class.metals.each { |app| @metals[app] = true } freeze @@ -44,7 +50,7 @@ module Rails def call(env) @metals.keys.each do |app| result = app.call(env) - return result unless result[0].to_i == 404 + return result unless @pass_through_on.include?(result[0].to_i) end @app.call(env) end |