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

[D-326] Store accessor support for assignable_values #50

Conversation

begerdom
Copy link
Member

No description provided.

@begerdom begerdom force-pushed the dominicbeger/d-326-store-accessor-support-for-assignable_values branch 3 times, most recently from 8435991 to bbbd4f5 Compare November 21, 2024 13:27
@begerdom begerdom force-pushed the dominicbeger/d-326-store-accessor-support-for-assignable_values branch 4 times, most recently from aae6356 to 2dabea7 Compare November 21, 2024 15:23
Copy link

@FLeinzi FLeinzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I don't have any opinion to that suggestion:

As store attribute are its own kind of attribute (like belongs_to relations), they should probably be handled in an own restriction class, like AssignableValues::ActiveRecord::Restriction::StoreAttribute to explicitly handle all peculiarities of store attributes.

For me this change would be enough as store accessors are similar to scalar attributes.

spec/assignable_values/active_record_spec.rb Outdated Show resolved Hide resolved
spec/assignable_values/active_record_spec.rb Outdated Show resolved Hide resolved
spec/assignable_values/active_record_spec.rb Show resolved Hide resolved
@triskweline
Copy link
Member

As store attribute are its own kind of attribute (like belongs_to relations), they should probably be handled in an own restriction class, like AssignableValues::ActiveRecord::Restriction::StoreAttribute to explicitly handle all peculiarities of store attributes.

The original gem design used multiple restriction classes to prevent the if/else clauses seen in this diff. The reader already needs to understand a lot of cases for covering various Rails versions.

If you find the restriction to be similiar to ScalarAttribute, you can inherit or extract a common module.

@begerdom begerdom force-pushed the dominicbeger/d-326-store-accessor-support-for-assignable_values branch from 2dabea7 to 5c2a432 Compare December 5, 2024 10:14
@begerdom begerdom force-pushed the dominicbeger/d-326-store-accessor-support-for-assignable_values branch from 5c2a432 to 8ce4ac4 Compare December 5, 2024 10:46
@begerdom begerdom merged commit ee22510 into master Dec 5, 2024
8 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.

3 participants