X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/43c411ec1441ee1710dc33389d7451f7414a170f..bb1d0c7499ad7c8d48c28a611c2d6a99c170265b:/services/api/lib/kind_and_etag.rb diff --git a/services/api/lib/kind_and_etag.rb b/services/api/lib/kind_and_etag.rb index 38a9288d0a..faf3ab04dd 100644 --- a/services/api/lib/kind_and_etag.rb +++ b/services/api/lib/kind_and_etag.rb @@ -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.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