Skip to content
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

refactor: better engine mounting #3533

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adrianthedev
Copy link
Collaborator

@adrianthedev adrianthedev commented Dec 15, 2024

Description

This PR refactors the way the Avo engine is mounted. Same for other Avo plugins.
This should significantly improve the way we recommend users to mount Avo when they are using the scope option.
I guess we could even remove the self.mount_avo_engines configuration option at some point.

# Other engines use this API to self-mount themselves
Avo.plugin_manager.mount_engine Avo::Collaborate::Engine, at: "/collaborate"

# like so...
module Avo
  module Collaborate
    class Engine < ::Rails::Engine
      isolate_namespace Avo::Collaborate

      initializer "avo-collaborate.init" do
        ActiveSupport.on_load(:avo_boot) do
          Avo.plugin_manager.register :avo_collaborate

          Avo.plugin_manager.mount_engine Avo::Collaborate::Engine, at: "/collaborate"
        end
      end
    end
  end
end

TODO

  • make mount_avo take a at: argument
  • cleanup
  • tests
  • update all other plugins to self-mount themselves
  • docs

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

Copy link

codeclimate bot commented Dec 15, 2024

Code Climate has analyzed commit 69e0f5a and detected 0 issues on this pull request.

View more on Code Climate.


def mount_engine(klass, **options)
puts ["mount_engine->", klass, options].inspect
@engines << { klass:, options: }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/SpaceInsideHashLiteralBraces: Space inside { detected.


def mount_engine(klass, **options)
puts ["mount_engine->", klass, options].inspect
@engines << { klass:, options: }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rubocop] reported by reviewdog 🐶
[Corrected] Layout/SpaceInsideHashLiteralBraces: Space inside } detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Next up
Development

Successfully merging this pull request may close these issues.

2 participants