Sha256: 8479d414ad82471e99ed421d62cce5a18a0713f11c4d4037ba7e3cbc80839d6b
Contents?: true
Size: 608 Bytes
Versions: 17
Compression:
Stored size: 608 Bytes
Contents
class Hash # creates a uniq sha1 digest of the hash's values # should mirror similar code in OneBody's lib/db_tools.rb def values_for_hash(*attrs) attrs = keys.sort unless attrs.any? attrs = attrs.first if attrs.first.is_a?(Array) values = attrs.map do |attr| value = self[attr.to_s] if value.respond_to?(:strftime) value.strftime('%Y-%m-%d %H:%M:%S') elsif value == true 1 elsif value == false 0 else value end end end def values_hash(*attrs) Digest::SHA1.hexdigest(values_for_hash(*attrs).join) end end
Version data entries
17 entries across 17 versions & 1 rubygems