| Module | Her::Model::Attributes |
| In: |
lib/her/model/attributes.rb
|
This module handles all methods related to model attributes
Initialize a new object with data
@param [Hash] attributes The attributes to initialize the object with @option attributes [Hash,Array] :_metadata @option attributes [Hash,Array] :_errors @option attributes [Boolean] :_destroyed
@example
class User
include Her::Model
end
User.new(name: "Tobias")
# => #<User name="Tobias">
User.new do |u|
u.name = "Tobias"
end
# => #<User name="Tobias">
Assign new attributes to a resource
@example
class User
include Her::Model
end
user = User.find(1) # => #<User id=1 name="Tobias">
user.assign_attributes(name: "Lindsay")
user.changes # => { :name => ["Tobias", "Lindsay"] }