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

Avoid monkey patching #164

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

adrianpacala
Copy link
Contributor

@adrianpacala adrianpacala commented Nov 16, 2024

Refactors the patches directory to leverage Ruby's module prepend mechanism instead of direct class_eval calls. This will introduce dedicated modules under the InertiaRails namespace that are systematically prepended to their target classes.

This architectural change offers several benefits:

  • Improves debugging capabilities through clearer stack traces
  • Better encapsulation of Rails core modifications
  • More maintainable and predictable method lookup chain

The new approach provides a cleaner separation of concerns while maintaining the same functional behavior of the original implementation.

Refactors the patches directory to leverage Ruby's module prepend mechanism
instead of direct `class_eval` calls. This will introduce dedicated modules under the
`InertiaRails` namespace that are systematically prepended to their target
classes.

This architectural change offers several benefits:

- Improves debugging capabilities through clearer stack traces
- Better encapsulation of Rails core modifications
- More maintainable and predictable method lookup chain

The new approach provides a cleaner separation of concerns while maintaining
the same functional behavior of the original implementation.

This commit rewrites the code in patches directory to avoid calling
`class_eval` directly. Instead, it defines modules defined under
`InertiaRails` namespaces that get prepended to their respective classes.
This should make things easier to debug as well as keeping the code
responsible for modifying the core Rails logic encapsulated
@bknoles
Copy link
Collaborator

bknoles commented Nov 21, 2024

looks good! Thanks @adrianpacala

@bknoles bknoles merged commit 602394f into inertiajs:master Nov 21, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants