我正在构建一个命名空间的Rails Engine gem,它可以通过其他gem来扩展。 例如:MyEngine是主要的gem,它也将是命名空间。 MyEngine-blog& MyEngine-support是可选的gem,用于在继承MyEngine名称空间时扩展MyEngine gem。
MyEngine-blog& MyEngine支持依赖于MyEngine的核心功能,两个gems将在其gemspec文件中包含spec.add_dependency "synculus"
。
为依赖项宝石指定Rails::Engine
的正确方法是什么?
我是否必须在每个MyEngine-blog&amp;中指定class Engine < ::Rails::Engine
? MyEngine-support gem的engine.rb文件?
# lib/myengine/engine.rb
module MyEngine
class Engine < ::Rails::Engine
isolate_namespace MyEngine
end
end
# lib/myengine/blog/engine.rb
module MyEngine
class Engine < ::Rails::Engine
isolate_namespace MyEngine
module Blog
end
end
end
# lib/myengine/support/engine.rb
module MyEngine
class Engine < ::Rails::Engine
isolate_namespace MyEngine
module Support
end
end
end