Ruby on Rails Thursday, May 2, 2013

What is the proper syntax to nest child modules within a parent module that is being as an isolate_namespace Rails engine gem?

# lib/myengine/engine.rb
module MyEngine
  class Engine < Rails::Engine
    isolate_namespace Myengine
    # def ...
  end
end


For example. The parent module is MyEngine and the child module is Blog. MyEngine will share common domain, like CRUD, Taggable, Searchable, etc, which will keep the gem code DRY and isolated from the main app (MyApp)

Are either of the two approaches correct? Any advice?

# A
# lib/myengine/blog.rb
module MyEngine
  module Blog
    # def ...
  end
end

# B
# lib/myengine/blog.rb
module MyEngine
  class Engine < Rails::Engine
    isolate_namespace Myengine
    module Blog
      # def ...
    end
  end
end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3gBcErT2ULUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment