virtus icon indicating copy to clipboard operation
virtus copied to clipboard

Add #update_attributes in mass assignment

Open artemeff opened this issue 10 years ago • 0 comments

#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?

artemeff avatar Aug 04 '15 21:08 artemeff