Method: Her::Model::ORM#reload

Defined in:
lib/her/model/orm.rb

#reload(options = nil) ⇒ Object

Refetches the resource

This method finds the resource by its primary key (which could be assigned manually) and modifies the object in-place.

Examples:

user = User.find(1)
# => #<User(users/1) id=1 name="Tobias Fünke">
user.name = "Oops"
user.reload # Fetched again via GET "/users/1"
# => #<User(users/1) id=1 name="Tobias Fünke">


154
155
156
157
158
# File 'lib/her/model/orm.rb', line 154

def reload(options = nil)
  fresh_object = self.class.find(id)
  assign_attributes(fresh_object.attributes)
  self
end