bitfield_attribute
bitfield_attribute copied to clipboard
Calling field.attributes freezes the Hash
Why does accessing .attributes
freeze the storage?
2.3.3 :013 > u = User.last
2.3.3 :014 > u.header_notify = { comment: false }
=> {:comment=>false}
2.3.3 :015 > u.header_notify.attributes
=> {:add_project=>true, :comment=>true, :reply=>false, :like=>true, :follow=>true, :mention=>true}
2.3.3 :016 > u.header_notify = { comment: false }
RuntimeError: can't modify frozen Hash
I suppose it is to prevent modification, but wouldn't .dup
be better?