-
Notifications
You must be signed in to change notification settings - Fork 93
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
Introduce #assign_preserving method #41
Comments
Hi @FunkyloverOne! Thanks for the reaching out, I like the idea! Let's design the API for it 🙂 I think it should be possible to patch the class Site
class Settings
include StoreModel::Model
attribute :twitter_handle, :string
# ...
attribute :colours, ColourScheme.to_type, default: -> { ColourScheme.new }, preserve: true
attribute :style, Styling.to_type, default: -> { Styling.new }, preserve: true
attribute :footer_pages, FooterPage.to_array_type, default: -> { [] }
end
end In this case |
Hey @DmitryTsepelev, one important thing is that we also need to have that Arrays preservation is not that easy as singular JSONs. You see, we need a way of identifying each individual element, updating/removing it, adding new ones. It is supposed to be similar to But we could start without arrays preservation support, it's already good enough 😄 |
Makes sense. We should probably change the name to something that can be easily associated with |
Which will preserve existing nested attributes :)
For me, it's quite a boilerplate code now, and it's useful, so I think it might be handy to be here out of the box.
Here's an example of something I already have:
And all the nested models have the same
assign_preserving
method, however theirNESTED_MODELS_TO_PRESERVE
might be blank.Yeah, and I guess we might have something more sophisticated than a constant of all nested models.
The text was updated successfully, but these errors were encountered: