-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add service generator #11265
Add service generator #11265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
@citizen428 the build is failing because of a naming issue:
|
@rhymes You caught me during lunch, I had already started working on this. The error you posted is a result of an attempt to fix it. Before it failed with this:
I was a bit dumbfounded, as we do everything the same way as in the data update generator. However, some googling seems to suggest that explicitly requiring
But this wasn't necessary for the |
This made me believe we manually updated the autoload path for the other generator and that's indeed the case: # config/initializers/zeitwerk.rb
# Ignoring folders that don't adhere to the new naming conventions
Rails.autoloaders.main.ignore(Rails.root.join("lib/data_update_scripts"))
Rails.autoloaders.main.ignore(Rails.root.join("lib/generators/data_update")) I added a line for the new generator now. |
Oops, accidentally merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I just suggested a change for what looks like a typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
* Add service generator * Finalize service generator * Add documentation * Explicitly require rails/generators * Update Zeitwerk initializer * Remove explicit require * Update docs/backend/service-objects.md Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
What type of PR is this? (check all applicable)
Description
I'm currently a bit blocked on profile work, waiting for 2 PRs to get approved and merged. So in the meantime I did some work on a service generator to standardize our service objects a bit more.
Examples:
Generate a non-namespaced service without arguments
$ rails generate service DoTheThing
Generate a non-namespaced service with arguments:
$ rails generate service DoTheThing arg1 arg2
The generated spec is the same as above.
Generate a namespaced service with arguments
$ rails generate service things/dothem arg1 arg2
Related Tickets & Documents
n/a
QA Instructions, Screenshots, Recordings
Try the different examples above and verify that the generated code matches your expectations.
Added tests?
Added to documentation?