Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika@curoverse.com>
[arvados.git] / services / api / lib / kind_and_etag.rb
index 9df128983950b17cc744f86731b387f7c55e8dc8..faf3ab04dd855585fda6ff027184c047d0a63163 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 module KindAndEtag
 
   def self.included(base)
@@ -5,13 +9,16 @@ module KindAndEtag
   end
 
   module ClassMethods
+    def kind
+      'arvados#' + self.to_s.camelcase(:lower)
+    end
   end
 
   def kind
-    'arvados#' + self.class.to_s.camelcase(:lower)
+    self.class.kind
   end
 
-  def etag
-    Digest::MD5.hexdigest(self.inspect).to_i(16).to_s(36)
+  def etag attrs=nil
+    Digest::MD5.hexdigest((attrs || self.attributes).inspect).to_i(16).to_s(36)
   end
 end