Merge branch '8784-dir-listings'
[arvados.git] / services / api / lib / kind_and_etag.rb
index 93f69f5bc5fb34dab3f7c5e83deb0d6a3d8d0719..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
-    'orvos#' + self.class.to_s.underscore
+    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