-
-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Lotus::String#deconstantize to detect application_module #67
Conversation
Changes Unknown when pulling cac6fcc on rail44:modify-loader-application-module into * on lotus:master*. |
Is test enough? And I've found that this PR make some of components have to be fixed. |
@rail44 Thanks for this PR, I think that this is the way to go. As a developer who wants to use Lotus, I expect that my controllers are nested under However, I don't like the implementation. The proof of what I'm saying is this code: def application_module
if @application_module
@application_module
else
deconstantize = Utils::String.new(application.name).deconstantize
if deconstantize.empty?
@application_module = application.class
else
@application_module = Utils::Class.load!(deconstantize)
end
end In the code above, we are moving the decision of which Ruby namespace to pick outside of two methods that supposed to take that decision. Other parts of the framework need to use this new logic, if we don't move that logic into What to do from now:
In this way, the other frameworks can stay untouched, because they will keep to use the same method (eg see |
@jodosha I comes up with following way for this issue, # Utils::String
def parents
parts = split(NAMESPACE_SEPARATOR)[0...-1]
parts.length.downto(1).map do |i|
self.class.new parts.slice(0, i).join(NAMESPACE_SEPARATOR)
end
end
# Configuration
def self.for(base)
modules = Utils::String.new(base).parents << 'Lotus'
framework = Utils::Class.load("(#{modules.join('|')})::Controller")
framework.configuration.duplicate
end How do you think about it? |
@rail44 I looked at the parts involved with this feature: it requires Model, View & Controller's Because this is a nice to have feature for now, and not a priority, the effort of changing all the frameworks it's not worth for now. Let's stick with: Bookshelf::Application # OK
Boohshelf::Backend # OK
Boohshelf::Frontend # OK
Boohshelf::Web # OK
Boohshelf::Whatever # OK
Boohshelf::Backend::Application # NOT OK Of course, if you find a clean solution, I'll be happy to merge it. Thank you! |
ty! |
Hi.
On defining following Application.
Lotus::Loader will load framework to toplevel module(Hoge) by this line
https://github.com/lotus/lotus/blob/41d1fe8624b5f26c111cc019283602fedc8fd237/lib/lotus/loader.rb#L98
This PR make the Loader will load framework into application's own parent module.
It depends on hanami/utils#28