Permalink
Browse files

Update generator config to support hiding namespaces and pass the app…

… into generator blocks
  • Loading branch information...
wycats committed May 24, 2011
1 parent ac3503c commit 9f815ee27cf5e4c6a649c83b497b27258d91cf6b
@@ -103,9 +103,10 @@ def load_tasks
self
end
- def load_generators
+ def load_generators(app=self)
initialize_generators
- railties.all { |r| r.load_generators }
+ railties.all { |r| r.load_generators(app) }
+
super
self
end
@@ -43,13 +43,15 @@ def merge_into(other)
class Generators #:nodoc:
attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging
+ attr_reader :hidden_namespaces
def initialize
@aliases = Hash.new { |h,k| h[k] = {} }
@options = Hash.new { |h,k| h[k] = {} }
@fallbacks = {}
@templates = []
@colorize_logging = true
+ @hidden_namespaces = []
end
def initialize_copy(source)
@@ -59,6 +61,10 @@ def initialize_copy(source)
@templates = @templates.dup
end
+ def hide_namespace(namespace)
+ @hidden_namespaces << namespace
+ end
+
def method_missing(method, *args)
method = method.to_s.sub(/=$/, '').to_sym
@@ -75,6 +75,7 @@ def self.configure!(config = Rails.application.config.generators) #:nodoc:
fallbacks.merge! config.fallbacks
templates_path.concat config.templates
templates_path.uniq!
+ hide_namespaces *config.hidden_namespaces
end
def self.templates_path
@@ -189,8 +189,8 @@ def load_tasks
end
end
- def load_generators
- self.class.generators.each(&:call)
+ def load_generators(app)
+ self.class.generators.each { |block| block.call(app) }
end
end
end

0 comments on commit 9f815ee

Please sign in to comment.