Module: Her::Model::ORM::UpdateMethods

Extended by:
ActiveSupport::Concern
Included in:
Her::Model::ORM
Defined in:
lib/her/model/orm/update_methods.rb

Instance Method Summary collapse

Instance Method Details

#update_attribute(attribute, value) ⇒ Object

Update resource attribute

Examples:

Update resource attribute

@user = User.find(1)
# Fetched via GET "/users/1"
@user.update_attributes(:fullname, "Tobias Fünke")
# Called via PUT "/users/1"


14
15
16
17
# File 'lib/her/model/orm/update_methods.rb', line 14

def update_attribute(attribute, value)
  send(attribute.to_s + '=', value)
  save
end

#update_attributes(attributes) ⇒ Object



19
20
21
22
# File 'lib/her/model/orm/update_methods.rb', line 19

def update_attributes(attributes)
  self.data.merge!(attributes)
  save
end

#update_attributes!(attributes) ⇒ Object



24
25
26
27
# File 'lib/her/model/orm/update_methods.rb', line 24

def update_attributes!(attributes)
  self.data.merge!(attributes)
  save!
end