Option to use `public_send` instead of `write_attribute` in AR Persistence layer?
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 5.2k
- Forks
- 644
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
AASM's ActiveRecord persistence uses write_attribute to persist. However, this doesn't work well with attributes that are not backed by exactly a single column. I want to use AASM with it's status attribute persisted as one of many attributes in a json column.
Describe the solution you'd like
It'd be nice to be able to support any attribute that is writable via public_send("#{atribbute_name}=", ?) so we can use attributes via:
store_accessor: https://api.rubyonrails.org/classes/ActiveRecord/Store.htmlstore_model: https://github.com/DmitryTsepelev/store_model
or any other methods that provide some form of "alternative persistence" to an ActiveRecord table wherein the attribute is not backed by a single column
Describe alternatives you've considered
# [override] Overriding this so that AASM can work with
# non-column based attributes
def write_attribute(key, value)
if key.to_sym == ':json_status`
public_send("json_status=", value)
else
super(key, value)
end
end
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 AASM's ActiveRecord persistence layer and the use of write_attribute; compare it with the requested public_send-based setter behavior. Done means supporting writable non-column attributes such as store_accessor and store_model while preserving existing ActiveRecord column persistence, with the behavior checked against those examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100