Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created July 17, 2010 09:15
Show Gist options
  • Save josevalim/479393 to your computer and use it in GitHub Desktop.
Save josevalim/479393 to your computer and use it in GitHub Desktop.
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 8794392..03c97bc 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -168,38 +168,52 @@ module Rails
def self.hidden_namespaces
@hidden_namespaces ||= begin
- orm = options[:rails][:orm]
- test = options[:rails][:test_framework]
- template = options[:rails][:template_engine]
-
- [
- "rails",
- "#{orm}:migration",
- "#{orm}:model",
- "#{orm}:observer",
- "#{orm}:session_migration",
- "#{test}:controller",
- "#{test}:helper",
- "#{test}:integration",
- "#{test}:mailer",
- "#{test}:model",
- "#{test}:observer",
- "#{test}:scaffold",
- "#{test}:view",
- "#{test}:performance",
- "#{test}:plugin",
- "#{template}:controller",
- "#{template}:scaffold",
- "#{template}:mailer"
- ]
+ hidden = ["rails"]
+
+ hide_namespace(:orm, options[:rails][:orm]).each do |orm|
+ hidden.concat [
+ "#{orm}:migration",
+ "#{orm}:model",
+ "#{orm}:observer",
+ "#{orm}:session_migration"
+ ]
+ end
+
+ hide_namespace(:test_framework, options[:rails][:test_framework]).each do |test|
+ hidden.concat [
+ "#{test}:controller",
+ "#{test}:helper",
+ "#{test}:integration",
+ "#{test}:mailer",
+ "#{test}:model",
+ "#{test}:observer",
+ "#{test}:scaffold",
+ "#{test}:view",
+ "#{test}:performance",
+ "#{test}:plugin"
+ ]
+ end
+
+ hide_namespace(:template_engine, options[:rails][:template_engine]).each do |template|
+ hidden.concat [
+ "#{template}:controller",
+ "#{template}:scaffold",
+ "#{template}:mailer"
+ ]
+ end
+
+ hidden
end
end
- class << self
- def hide_namespaces(*namespaces)
- hidden_namespaces.concat(namespaces)
- end
- alias hide_namespace hide_namespaces
+ def self.hide_namespace(kind, name=nil)
+ @hide_namespace ||= Hash.new { |h,k| h[k] = [] }
+ @hide_namespace[kind] << name if name
+ @hide_namespace[kind]
+ end
+
+ def self.show_namespace(kind, name)
+ hide_namespace(kind).delete(name)
end
# Show help message with available generators.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment