Skip to content
Browse files

Add Rails::Railtie.railtie_name method to allow setting custom name f…

…or railtie
  • Loading branch information...
1 parent b52dfc6 commit bfccbc6df91a3c24bbf99262383c6f1e9069e1dd @drogus drogus committed Jul 26, 2010
View
9 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -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)
View
4 railties/lib/rails/plugin.rb
@@ -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
View
7 railties/lib/rails/railtie.rb
@@ -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
View
1 railties/test/railties/engine_test.rb
@@ -28,6 +28,7 @@ def setup
plugin.write "lib/bukkits.rb", <<-RUBY
class Bukkits
class Engine < ::Rails::Engine
+ railtie_name "bukkits"
end
end
RUBY

0 comments on commit bfccbc6

Please sign in to comment.
Something went wrong with that request. Please try again.