Update generator config to support hiding namespaces and pass the app into generator blocks

This commit is contained in:
wycats
2011-05-24 16:03:15 -07:00
parent 74ade51eee
commit c1df4425b6
4 changed files with 12 additions and 4 deletions

View File

@@ -103,9 +103,10 @@ module Rails
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

View File

@@ -43,6 +43,7 @@ module Rails
class Generators #:nodoc:
attr_accessor :aliases, :options, :templates, :fallbacks, :colorize_logging
attr_reader :hidden_namespaces
def initialize
@aliases = Hash.new { |h,k| h[k] = {} }
@@ -50,6 +51,7 @@ module Rails
@fallbacks = {}
@templates = []
@colorize_logging = true
@hidden_namespaces = []
end
def initialize_copy(source)
@@ -59,6 +61,10 @@ module Rails
@templates = @templates.dup
end
def hide_namespace(namespace)
@hidden_namespaces << namespace
end
def method_missing(method, *args)
method = method.to_s.sub(/=$/, '').to_sym

View File

@@ -75,6 +75,7 @@ module Rails
fallbacks.merge! config.fallbacks
templates_path.concat config.templates
templates_path.uniq!
hide_namespaces *config.hidden_namespaces
end
def self.templates_path

View File

@@ -189,8 +189,8 @@ module Rails
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