Skip to content

Refactor Meilisearch::Index class into focused modules#677

Open
psylone wants to merge 6 commits intomeilisearch:mainfrom
psylone:refactoring/index
Open

Refactor Meilisearch::Index class into focused modules#677
psylone wants to merge 6 commits intomeilisearch:mainfrom
psylone:refactoring/index

Conversation

@psylone
Copy link
Copy Markdown
Contributor

@psylone psylone commented Feb 11, 2026

Pull Request

Related issue

Fixes #676

What does this PR do?

  • Refactor Meilisearch::Index class

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
    • Used Claude Code for writing more accurate module docs
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d4a911e) to head (990dfd8).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #677   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        16    +6     
  Lines          809       835   +26     
=========================================
+ Hits           809       835   +26     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@psylone psylone mentioned this pull request Feb 11, 2026
3 tasks
@curquiza curquiza added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Feb 26, 2026
end
end

include Compact
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi there! I loved your PR altough I have one question regarding the class reopening during these module definitions. I think I have never seen this being used like this. Is there any benefit to it over regular mixin usage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback! Let me explain the reasoning behind this decision.

First of all, we need to ensure that Meilisearch::Index inherits from Meilisearch::HTTPRequest, which means lib/meilisearch/index.rb must be loaded before the submodules since they reopen class Index.

That's why we can't place require 'meilisearch/index/compact' at the top of lib/meilisearch/index.rb: the modules must be required after the class Index < HTTPRequest definition.

We could place include Compact right after the require statements, but I prefer to put it inside the Compact module definition to make it self-contained and keep Meilisearch::Index cleaner.

You might also wonder: why not use plain mixins like Meilisearch::IndexCompact and require/include them the usual way? That's certainly possible, and I considered it.

However, I find it cleaner to define Meilisearch::Index::Compact as a nested module and place it under the lib/meilisearch/index folder - it better reflects the logical hierarchy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@brunoocasali so what do you think?

Max: 24

# Offense count: 4
# Offense count: 3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Anything related to maintenance (CI, tests, refactoring...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Meilisearch::Index class

3 participants