Expand key to be a consistent string value. Invoke cache_key if
object responds to cache_key. Otherwise, to_param method will be
called. If the key is a Hash, then keys will be
sorted alphabetically.
# File activesupport/lib/active_support/cache.rb, line 486
def expanded_key(key) # :nodoc:
if key.respond_to?(:cache_key)
key = key.cache_key.to_s
elsif key.is_a?(Array)
if key.size > 1
key.collect{|element| expanded_key(element)}.to_param
else
key.first.to_param
end
elsif key.is_a?(Hash)
key = key.to_a.sort{|a,b| a.first.to_s <=> b.first.to_s}.collect{|k,v| "#{k}=#{v}"}.to_param
else
key = key.to_param
end
end