virtus
virtus copied to clipboard
Add #update_attributes in mass assignment
#attributes= method behaves like set these attributes for this object in my mind, but works like update provided attributes in object, and I'm feel wrong when using it in this way.
require 'virtus'
class User
include Virtus.model
attribute :name
attribute :age
end
user = User.new(name: 'John Doe', age: 21)
# => #<User:0x007fe7b38d71e0 @name="John Doe", @age=21>
user.attributes = { name: 'John Snow' }
# => #<User:0x007fe7b38d71e0 @name="John Snow", @age=21>
# maybe there could be #update_attributes
What do you think?