提交 bfccbc6d 编写于 作者: P Piotr Sarnacki

Add Rails::Railtie.railtie_name method to allow setting custom name for railtie

上级 b52dfc67
......@@ -277,8 +277,13 @@ def default_url_options=(options)
private
def app_name(app)
return unless app.respond_to?(:routes)
class_name = app.class.is_a?(Class) ? app.name : app.class.name
ActiveSupport::Inflector.underscore(class_name).gsub("/", "_")
if app.respond_to?(:railtie_name)
app.railtie_name
else
class_name = app.class.is_a?(Class) ? app.name : app.class.name
ActiveSupport::Inflector.underscore(class_name).gsub("/", "_")
end
end
def define_generate_prefix(app, name)
......
......@@ -48,6 +48,10 @@ def self.all(list, paths)
attr_reader :name, :path
def railtie_name
name.to_s
end
def load_tasks
super
load_deprecated_tasks
......
......@@ -164,8 +164,15 @@ def generators(&blk)
def abstract_railtie?
ABSTRACT_RAILTIES.include?(name)
end
def railtie_name(name = nil)
@railtie_name = name if name
@railtie_name ||= ActiveSupport::Inflector.underscore(self.name).gsub("/", "_")
end
end
delegate :railtie_name, :to => "self.class"
def config
@config ||= Railtie::Configuration.new
end
......
......@@ -28,6 +28,7 @@ def setup
plugin.write "lib/bukkits.rb", <<-RUBY
class Bukkits
class Engine < ::Rails::Engine
railtie_name "bukkits"
end
end
RUBY
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册