Browse files

Rename namespace method to isolate_namespace.

This change caused by confusion caused by calling engine
"namespaced". Stuff inside engine can be namespaced for every
engine. This method is not actually namespacing anything, it's
isolating engine within the given namespace.
  • Loading branch information...
1 parent afd76d7 commit 5d5eb2b18d364cb27d2062668bd3b1921b1040a8 @drogus drogus committed Oct 9, 2010
View
20 railties/lib/rails/engine.rb
@@ -214,11 +214,11 @@ module Rails
# as they would be created inside application. One of the cosequences of that is including
# application's helpers and url_helpers inside controller. Sometimes, especially when your
# engine provides its own routes, you don't want that. To isolate engine's stuff from application
- # you can use namespace method:
+ # you can use isolate_namespace method:
#
# module MyEngine
# class Engine < Rails::Engine
- # namespace MyEngine
+ # isolate_namespace MyEngine
# end
# end
#
@@ -252,7 +252,7 @@ module Rails
# end
#
#
- # Additionaly namespaced engine will set its name according to namespace, so in that case:
+ # Additionaly isolated engine will set its name according to namespace, so in that case:
# MyEngine::Engine.engine_name #=> "my_engine" and it will set MyEngine.table_name_prefix
# to "my_engine_".
#
@@ -315,7 +315,7 @@ class Engine < Railtie
autoload :Configuration, "rails/engine/configuration"
class << self
- attr_accessor :called_from, :namespaced
+ attr_accessor :called_from, :isolated
alias :engine_name :railtie_name
def inherited(base)
@@ -350,12 +350,12 @@ def endpoint(endpoint = nil)
@endpoint
end
- def namespace(mod)
+ def isolate_namespace(mod)
engine_name(generate_railtie_name(mod))
name = engine_name
self.routes.default_scope = {:module => name}
- self.namespaced = true
+ self.isolated = true
unless mod.respond_to?(:_railtie)
_railtie = self
@@ -371,13 +371,13 @@ def namespace(mod)
end
end
- def namespaced?
- !!namespaced
+ def isolated?
+ !!isolated
end
end
delegate :middleware, :root, :paths, :to => :config
- delegate :engine_name, :namespaced?, :to => "self.class"
+ delegate :engine_name, :isolated?, :to => "self.class"
def load_tasks
super
@@ -506,7 +506,7 @@ def load_seed
end
initializer :prepend_helpers_path do |app|
- if !namespaced? || (app == self)
+ if !isolated? || (app == self)
app.config.helpers_paths.unshift(*paths["app/helpers"].existent)
end
end
View
4 railties/test/generators/namespaced_generators_test.rb
@@ -6,14 +6,14 @@
class NamespacedGeneratorTestCase < Rails::Generators::TestCase
def setup
- TestApp::Application.namespace(TestApp)
+ TestApp::Application.isolate_namespace(TestApp)
end
def teardown
if TestApp.respond_to?(:_railtie)
TestApp.singleton_class.send(:undef_method, :_railtie)
TestApp.singleton_class.send(:undef_method, :table_name_prefix)
- TestApp::Application.namespaced = false
+ TestApp::Application.isolated = false
end
end
end
View
16 railties/test/railties/engine_test.rb
@@ -394,7 +394,7 @@ def bar
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
- namespace Bukkits
+ isolate_namespace Bukkits
end
end
RUBY
@@ -511,7 +511,7 @@ class MyMailer < ActionMailer::Base
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
- namespace Bukkits
+ isolate_namespace Bukkits
end
end
RUBY
@@ -572,7 +572,7 @@ def new
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
- namespace(Bukkits)
+ isolate_namespace(Bukkits)
end
end
RUBY
@@ -593,7 +593,7 @@ class Engine < ::Rails::Engine
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
- namespace(Bukkits)
+ isolate_namespace(Bukkits)
paths["public"] = "#{File.join(@plugin.path, "alternate_public")}"
end
end
@@ -611,7 +611,7 @@ class Engine < ::Rails::Engine
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
- namespace(Bukkits)
+ isolate_namespace(Bukkits)
paths["public"] = "#{File.join(@plugin.path, "not_existing")}"
end
end
@@ -648,12 +648,12 @@ class Engine < ::Rails::Engine
@plugin.write "lib/bukkits.rb", <<-RUBY
module AppTemplate
class Engine < ::Rails::Engine
- namespace(AppTemplate)
+ isolate_namespace(AppTemplate)
end
end
RUBY
- add_to_config "namespace AppTemplate"
+ add_to_config "isolate_namespace AppTemplate"
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do end
@@ -686,7 +686,7 @@ class Engine < ::Rails::Engine
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
- namespace(Bukkits)
+ isolate_namespace(Bukkits)
end
end
RUBY
View
2 railties/test/railties/mounted_engine_test.rb
@@ -49,7 +49,7 @@ def new_record?
@plugin.write "lib/blog.rb", <<-RUBY
module Blog
class Engine < ::Rails::Engine
- namespace(Blog)
+ isolate_namespace(Blog)
end
end
RUBY

0 comments on commit 5d5eb2b

Please sign in to comment.