mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add Rails::Railtie.railtie_name method to allow setting custom name for railtie
This commit is contained in:
@@ -277,8 +277,13 @@ module ActionDispatch
|
||||
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 @@ module Rails
|
||||
|
||||
attr_reader :name, :path
|
||||
|
||||
def railtie_name
|
||||
name.to_s
|
||||
end
|
||||
|
||||
def load_tasks
|
||||
super
|
||||
load_deprecated_tasks
|
||||
|
||||
@@ -164,8 +164,15 @@ module Rails
|
||||
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 @@ module RailtiesTest
|
||||
plugin.write "lib/bukkits.rb", <<-RUBY
|
||||
class Bukkits
|
||||
class Engine < ::Rails::Engine
|
||||
railtie_name "bukkits"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
Reference in New Issue
Block a user