instance method
expanded_key
Ruby on Rails 5.2.8.1
Since v5.2.8.1 Private — implementation detail, not part of the public APISignature
expanded_key(key)
Expands key to be a consistent string value. Invokes 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.
Parameters
-
keyreq
Source
# File activesupport/lib/active_support/cache.rb, line 629
def expanded_key(key)
return key.cache_key.to_s if key.respond_to?(:cache_key)
case key
when Array
if key.size > 1
key = key.collect { |element| expanded_key(element) }
else
key = key.first
end
when Hash
key = key.sort_by { |k, _| k.to_s }.collect { |k, v| "#{k}=#{v}" }
end
key.to_param
end
Defined in activesupport/lib/active_support/cache.rb line 629
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::Store