Skip to content

improvement: Add Ash.Subject to abstract Changeset, Query, ActionInput common functions#2212

Merged
zachdaniel merged 3 commits intoash-project:mainfrom
chazwatkins:improvement/ash_subject
Jul 21, 2025
Merged

improvement: Add Ash.Subject to abstract Changeset, Query, ActionInput common functions#2212
zachdaniel merged 3 commits intoash-project:mainfrom
chazwatkins:improvement/ash_subject

Conversation

@chazwatkins
Copy link
Copy Markdown
Contributor

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Adds Ash.Subject to help abstract common functionality between Changeset, Query, and ActionInput. Most functions act as a router to the subject's corresponding function. For any functions that seemed to have generic implementations, I moved those into Ash.Subject directly.

No changes have been made to Changeset, Query, or ActionInput. This PR only adds Ash.Subject so it can be used when refactoring other functionality that has to pattern match on the subject type.

Let me know if any changes are needed.

Future PRs will aim to refactor modules that are currently pattern matching on subject type to call the common functions and eventually pull out the logic from the subject type modules into Ash.Subject so it's all centralized.

@chazwatkins chazwatkins changed the title improvement: Add Ash.Subject to abstract Changeset, Query, ActionInput improvement: Add Ash.Subject to abstract Changeset, Query, ActionInput common functions Jul 20, 2025
@chazwatkins chazwatkins force-pushed the improvement/ash_subject branch 3 times, most recently from b7f3967 to 7469bb1 Compare July 20, 2025 07:06
@chazwatkins chazwatkins force-pushed the improvement/ash_subject branch from 7469bb1 to 24a5b58 Compare July 20, 2025 07:12
Comment thread lib/ash/subject.ex Outdated
Comment thread lib/ash/subject.ex Outdated
Comment thread lib/ash/subject.ex Outdated
Comment thread lib/ash/subject.ex Outdated
- Remove `set_actor`, `set_tenant`, `set_tracer`, `set_authorize?`
- Remove `set_result` and `clear_result` until `ActionInput` supports it
@chazwatkins
Copy link
Copy Markdown
Contributor Author

Addressed all the feedback items

@chazwatkins chazwatkins force-pushed the improvement/ash_subject branch from 8e750f7 to 7fe19a7 Compare July 20, 2025 14:32
@chazwatkins
Copy link
Copy Markdown
Contributor Author

Fixed the dialyzer issue for add_error type specs. Should be good to review once ci completes.

@chazwatkins
Copy link
Copy Markdown
Contributor Author

I went ahead and added set_result and clear_result for all subject types

Comment thread lib/ash/subject.ex Outdated
@chazwatkins chazwatkins force-pushed the improvement/ash_subject branch from 66aaa7e to 7fe19a7 Compare July 21, 2025 02:25
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

@zachdaniel zachdaniel merged commit 0808869 into ash-project:main Jul 21, 2025
77 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

Awesome 😄 PRing the usage of this to the builtin preparations, validations, and changes would be amazing ❤️

@chazwatkins
Copy link
Copy Markdown
Contributor Author

Awesome 😄 PRing the usage of this to the builtin preparations, validations, and changes would be amazing ❤️

I'll work on that this week and get it submitted.

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