Merge branch '8784-dir-listings'
[arvados.git] / services / api / lib / kind_and_etag.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 module KindAndEtag
6
7   def self.included(base)
8     base.extend(ClassMethods)
9   end
10
11   module ClassMethods
12     def kind
13       'arvados#' + self.to_s.camelcase(:lower)
14     end
15   end
16
17   def kind
18     self.class.kind
19   end
20
21   def etag attrs=nil
22     Digest::MD5.hexdigest((attrs || self.attributes).inspect).to_i(16).to_s(36)
23   end
24 end