luckyframework / luckyframework/avram
Normalizing callbacks for escape-hatch usage
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
The current callbacks are `before_save`, `after_save`, `after_commit` for SaveOperation, `before_delete`, `after_delete` for DeleteOperation, and `before_run`, `after_run` for Operation. With the exception of `after_commit`, these all do the exact same thing in their perspective positions.
One thing we could do is make `before_save` and `before_delete` just call `before_run`. Likewise for `after_save` and `after_delete`. Then these essentially are just syntactic sugar aliases used for clarity and convention. The benefit here would be if you wanted something special to happen before any sort of operation, you could create a module that just calls `before_run` and include that in every operation type and it would work.
The `after_commit` works the same, but the issue is that it's called in a different spot. We wouldn't want this added in to the `after_run` chain.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the callback definitions for SaveOperation, DeleteOperation, and Operation, then trace where before_run, after_run, and after_commit are invoked. The refactor is done when before_save and before_delete share the before_run behavior, after_save and after_delete share after_run behavior, and after_commit remains separate at its existing point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- databases
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100