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

write_attributes / attributes= method #426

Open
etipton opened this issue Apr 17, 2020 · 2 comments
Open

write_attributes / attributes= method #426

etipton opened this issue Apr 17, 2020 · 2 comments

Comments

@etipton
Copy link

etipton commented Apr 17, 2020

Thoughts on adding something like this (possibly naming it attributes=)?

    # Analagous to ActiveRecord's #attributes= -- allows for writing attributes via a hash
    def write_attributes(attrs)
      attrs.each do |attr, val|
        write_attribute(attr, val)
      end
    end
@andrykonchin
Copy link
Member

Yes, it's a good idea to follow the Rails naming conventions and PR is welcomed.

But unfortunately there is already attributes accessor (defined here). It's too low-level and doesn't cast attribute values. So it makes sense to change it with proposed implementation. But it would be a breaking change so I believe we should wait until the next major release.

There is similar method #load (here) which is used completely internally but accidentally public. It could be used for now and later in the next major release it will become private.

@etipton
Copy link
Author

etipton commented Apr 20, 2020

Thanks for the quick response!

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

No branches or pull requests

2 participants