solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 228 forks source link

Add #update_attributes in mass assignment #331

Open artemeff opened 8 years ago

artemeff commented 8 years ago

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