Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-cache/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#to_sha2Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/merb-cache/core_ext/hash.rb', line 5

def to_sha2
  string = ""
  keys.sort_by{|k| k.to_s}.each do |k| 
    case self[k]
    when Array
      string << self[k].join
    when Hash
      string << self[k].to_sha2
    else
      string << self[k].to_s
    end
  end
  Digest::SHA2.hexdigest(string)
end