update server-assigned attributes after saving objects
authorTom Clegg <tom@clinicalfuture.com>
Thu, 7 Feb 2013 16:13:26 +0000 (11:13 -0500)
committerTom Clegg <tom@clinicalfuture.com>
Thu, 7 Feb 2013 16:13:26 +0000 (11:13 -0500)
app/models/orvos_base.rb

index 96016059cad97d232c5a177698cafaf117cc5cc5..9a02001c9b8b8159aefdd68fb0a199ff9b26cc8e 100644 (file)
@@ -55,9 +55,18 @@ class OrvosBase < ActiveRecord::Base
       resp = $orvos_api_client.api(self.class, '', postdata)
     end
     return false if !resp[:etag] || !resp[:uuid]
+
+    # set read-only non-database attributes
     @etag = resp[:etag]
     @kind = resp[:kind]
-    self.uuid ||= resp[:uuid]
+
+    # these attrs can be modified by "save" -- we should update our copies
+    %w(uuid owner created_at
+       modified_at modified_by_user modified_by_client
+      ).each do |attr|
+      self.send(attr + '=', resp[attr.to_sym])
+    end
+
     self
   end
   def save!